Skip to content

Commit

Permalink
Adding 'enableShiftDrag' if we want to keep the original Leaflet func…
Browse files Browse the repository at this point in the history
…tionality on top of having the button.
  • Loading branch information
avidspartan1 committed Apr 21, 2017
1 parent 86dceab commit 75f9091
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Then add the Control to your map:

# Options

* **enableShiftDrag** Enable the original functionality of Leaflet's shift-drag box zoom, in addition to the button.
* **iconClasses** Any valid classes for an icon element. Used for easily adding a custom icon to the button.
* **iconColor** Use to set the color of the custom icon. Accepts anything valid for a standard CSS color value, e.g. "black", "#000000", etc. Defaults to "black".
* **keepOn** Boolean. Controls whether the zoombox state ends when drawing a zoom, or whether it's kept on. Defaults to false.
Expand Down
8 changes: 6 additions & 2 deletions dist/leaflet-control-boxzoom-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ L.Control.BoxZoom = L.Control.extend({
L.DomUtil.addClass(this.controlDiv,'leaflet-control-boxzoom-active');
this.active = true;
this.map.dragging.disable();
this.map.boxZoom.addHooks();
if (!this.options.enableShiftDrag) {
this.map.boxZoom.addHooks();
}

this.map.on('mousedown', this.handleMouseDown, this);
this.map.on('boxzoomend', this.setStateOff, this);
Expand All @@ -72,7 +74,9 @@ L.Control.BoxZoom = L.Control.extend({
this.active = false;
this.map.off('mousedown', this.handleMouseDown, this);
this.map.dragging.enable();
this.map.boxZoom.removeHooks();
if (!this.options.enableShiftDrag) {
this.map.boxZoom.removeHooks();
}

L.DomUtil.removeClass(this.map._container,'leaflet-control-boxzoom-active');
},
Expand Down
2 changes: 1 addition & 1 deletion dist/leaflet-control-boxzoom.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 75f9091

Please sign in to comment.