Skip to content

Commit 43aad07

Browse files
byzhengjcheng5
authored andcommitted
fixed scrollWheelZoom to disable scroll zoom
See #464
1 parent 5c2a924 commit 43aad07

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

javascript/src/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,20 @@ function preventUnintendedZoomOnScroll(map) {
6868
});
6969
$(document).on("mousemove", "*", function(e) {
7070
// Did the mouse really move?
71-
if (lastScreen.x !== null && e.screenX !== lastScreen.x || e.screenY !== lastScreen.y) {
72-
// It really moved. Enable zooming.
73-
map.scrollWheelZoom.enable();
74-
lastScreen = {x: null, y: null};
71+
if (map.options.scrollWheelZoom) {
72+
if (lastScreen.x !== null && e.screenX !== lastScreen.x || e.screenY !== lastScreen.y) {
73+
// It really moved. Enable zooming.
74+
map.scrollWheelZoom.enable();
75+
lastScreen = {x: null, y: null};
76+
}
7577
}
7678
});
7779
$(document).on("mousedown", ".leaflet", function(e) {
7880
// Clicking always enables zooming.
79-
map.scrollWheelZoom.enable();
80-
lastScreen = {x: null, y: null};
81+
if (map.options.scrollWheelZoom) {
82+
map.scrollWheelZoom.enable();
83+
lastScreen = {x: null, y: null};
84+
}
8185
});
8286
}
8387

0 commit comments

Comments
 (0)