Skip to content

Commit e13514a

Browse files
authored
Merge pull request #11 from edfungus/patch-1
Fix bug where touch event still propagated
2 parents 40d770b + 512b096 commit e13514a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Leaflet.DoubleTapDragZoom.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var DoubleTapDragZoom = L.Handler.extend({
1010
this._map.on('doubletapdragstart', this._onDoubleTapDragStart, this);
1111
this._map.on('doubletapdrag', this._onDoubleTapDrag, this);
1212
this._map.on('doubletapdragend', this._onDoubleTapDragEnd, this);
13+
L.DomEvent.on(this._map._container, 'touchmove', this._onDragging, this);
1314
},
1415

1516
removeHooks: function () {
@@ -20,7 +21,6 @@ var DoubleTapDragZoom = L.Handler.extend({
2021

2122
_onDoubleTapDragStart: function (e) {
2223
var map = this._map;
23-
2424
if (!e.touches || e.touches.length !== 1 || map._animatingZoom) { return; }
2525

2626
var p = map.mouseEventToContainerPoint(e.touches[0]);
@@ -39,6 +39,7 @@ var DoubleTapDragZoom = L.Handler.extend({
3939

4040
map._stop();
4141
map._moveStart(true, false);
42+
this._doubleTapDragging = true;
4243
},
4344

4445
_onDoubleTapDrag: function (e) {
@@ -90,6 +91,14 @@ var DoubleTapDragZoom = L.Handler.extend({
9091
}
9192

9293
this._center = null;
94+
this._doubleTapDragging = false;
95+
},
96+
97+
_onDragging: function (e) {
98+
if (this._doubleTapDragging) {
99+
L.DomEvent.preventDefault(e);
100+
L.DomEvent.stopPropagation(e);
101+
}
93102
}
94103
});
95104

0 commit comments

Comments
 (0)