Skip to content

Commit

Permalink
ignore multi touch 2
Browse files Browse the repository at this point in the history
  • Loading branch information
petoc committed Feb 28, 2024
1 parent ec42412 commit 08df798
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@petoc/leaflet-double-touch-drag-zoom",
"version": "1.0.1",
"version": "1.0.3",
"author": "Peter C.",
"license": "MIT",
"description": "Leaflet plugin for one finger zoom.",
Expand Down
16 changes: 13 additions & 3 deletions src/leaflet-double-touch-drag-zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

var DoubleTouchDragZoom = L.Handler.extend({
addHooks: function () {
this._eventCache = [];
this._onTouchStart = this._onTouchStart.bind(this);
this._onTouchMove = this._onTouchMove.bind(this);
this._onTouchEnd = this._onTouchEnd.bind(this);
Expand Down Expand Up @@ -75,10 +76,9 @@
},

_onTouchStart: function (e) {
console.log(e.touches);
if (this._map._animatingZoom || this._zooming
|| (this._touchStartEvent && this._touchStartEvent !== e.type)
|| (e.touches && e.touches.length > 1)
|| (this._touchStartEvent && this._touchStartEvent !== e.type)
|| this._eventCache.length > 1
) {
return;
}
Expand All @@ -88,6 +88,11 @@
this._doubleTouch = this._lastTouchTime && ((now - this._lastTouchTime) <= this._map.options.doubleTouchDragZoomDelay);
this._eventNameMove = e.type.replace('start', 'move').replace('down', 'move');
this._eventNameEnd = e.type.replace('start', 'end').replace('down', 'up');
this._eventCache.push(e);
var that = this;
document.addEventListener(this._eventNameEnd, function () {
that._eventCache.pop();
});

if (this._doubleTouch) {
L.DomUtil.addClass(this._map._container, 'leaflet-double-touch');
Expand Down Expand Up @@ -117,6 +122,11 @@
},

_onTouchMove: function (e) {
if (this._eventCache.length > 1) {
this._onTouchEnd();
return;
}

if (!this._zooming) { return; }

if (this._doubleTouch) {
Expand Down

0 comments on commit 08df798

Please sign in to comment.