Skip to content

Commit

Permalink
Add preventDefault() to avoid page scroll while panning
Browse files Browse the repository at this point in the history
Enabling dragging of a map changes the touch-action CSS property
value to prevent the page from scrolling while you are dragging.

However, when dragging is enabled dynamically inside a touch event
this CSS change doesn't affect the current gesture.

Add e.preventDefault() in the event handler to prevent the page
from scrolling while you're performing a two-finger drag action
on the map.
  • Loading branch information
gofr committed May 26, 2021
1 parent c75fcf0 commit 19dacba
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/js/leaflet-gesture-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export var GestureHandling = L.Handler.extend({
);
this._disableInteractions();
} else {
e.preventDefault();
this._enableInteractions();
L.DomUtil.removeClass(this._map._container,
"leaflet-gesture-handling-touch-warning"
Expand Down

0 comments on commit 19dacba

Please sign in to comment.