Skip to content

Commit

Permalink
check map drag state before changing it - fix #189
Browse files Browse the repository at this point in the history
  • Loading branch information
codeofsumit committed Aug 3, 2017
1 parent a4b094f commit 7d1a0a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions demo/demo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable */

const map2 = L.map('example2').setView([51.505, -0.09], 13);
// map2.dragging.disable();

map2.on('pm:create', function(e) {
// alert('pm:create event fired. See console for details');
Expand Down
12 changes: 10 additions & 2 deletions src/js/Mixins/Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const DragMixin = {
const el = this._layer._path;

// re-enable map drag
this._layer._map.dragging.enable();
if(this._originalMapDragState) {
this._layer._map.dragging.enable();
}

// clear up mousemove event
this._layer._map.off('mousemove', this._dragMixinOnMouseMove, this);
Expand Down Expand Up @@ -57,7 +59,10 @@ const DragMixin = {
this._layer.bringToFront();

// disbale map drag
this._layer._map.dragging.disable();
if(this._originalMapDragState) {
this._layer._map.dragging.disable();
}


// hide markers
this._markerGroup.clearLayers();
Expand All @@ -69,6 +74,9 @@ const DragMixin = {
this._onLayerDrag(e);
},
_dragMixinOnMouseDown(e) {
// save current map dragging state
this._originalMapDragState = this._layer._map.dragging._enabled;

// save for delta calculation
this._tempDragCoord = e.latlng;

Expand Down

0 comments on commit 7d1a0a0

Please sign in to comment.