* Fix #4592 by falling back to a legacy ScrollEvent property on Edge. * Improve consistency of scroll zoom by rounding everything to 60px
This commit is contained in:
parent
87e38f1aa4
commit
cd30e283cf
@ -228,22 +228,23 @@ L.DomEvent = {
|
|||||||
// Chrome on Win scrolls double the pixels as in other platforms (see #4538),
|
// Chrome on Win scrolls double the pixels as in other platforms (see #4538),
|
||||||
// and Firefox scrolls device pixels, not CSS pixels
|
// and Firefox scrolls device pixels, not CSS pixels
|
||||||
_wheelPxFactor: (L.Browser.win && L.Browser.chrome) ? 2 :
|
_wheelPxFactor: (L.Browser.win && L.Browser.chrome) ? 2 :
|
||||||
(L.Browser.gecko) ? window.devicePixelRatio :
|
L.Browser.gecko ? window.devicePixelRatio :
|
||||||
1,
|
1,
|
||||||
|
|
||||||
// @function getWheelDelta(ev: DOMEvent): Number
|
// @function getWheelDelta(ev: DOMEvent): Number
|
||||||
// Gets normalized wheel delta from a mousewheel DOM event, in vertical
|
// Gets normalized wheel delta from a mousewheel DOM event, in vertical
|
||||||
// pixels scrolled (negative if scrolling down).
|
// pixels scrolled (negative if scrolling down).
|
||||||
// Events from pointing devices without precise scrolling are mapped to
|
// Events from pointing devices without precise scrolling are mapped to
|
||||||
// a best guess of between 50-60 pixels.
|
// a best guess of 60 pixels.
|
||||||
getWheelDelta: function (e) {
|
getWheelDelta: function (e) {
|
||||||
return (e.deltaY && e.deltaMode === 0) ? -e.deltaY / L.DomEvent._wheelPxFactor : // Pixels
|
return (L.Browser.edge) ? e.wheelDeltaY / 2 : // Don't trust window-geometry-based delta
|
||||||
(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 18 : // Lines
|
(e.deltaY && e.deltaMode === 0) ? -e.deltaY / L.DomEvent._wheelPxFactor : // Pixels
|
||||||
(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 52 : // Pages
|
(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines
|
||||||
|
(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages
|
||||||
(e.deltaX || e.deltaZ) ? 0 : // Skip horizontal/depth wheel events
|
(e.deltaX || e.deltaZ) ? 0 : // Skip horizontal/depth wheel events
|
||||||
e.wheelDelta ? (e.wheelDeltaY || e.wheelDelta) / 2 : // Legacy IE pixels
|
e.wheelDelta ? (e.wheelDeltaY || e.wheelDelta) / 2 : // Legacy IE pixels
|
||||||
(e.detail && Math.abs(e.detail) < 32765) ? -e.detail * 18 : // Legacy Moz lines
|
(e.detail && Math.abs(e.detail) < 32765) ? -e.detail * 20 : // Legacy Moz lines
|
||||||
e.detail ? e.detail / -32765 * 52 : // Legacy Moz pages
|
e.detail ? e.detail / -32765 * 60 : // Legacy Moz pages
|
||||||
0;
|
0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ L.Map.mergeOptions({
|
|||||||
// How many scroll pixels (as reported by [L.DomEvent.getWheelDelta](#domevent-getwheeldelta))
|
// How many scroll pixels (as reported by [L.DomEvent.getWheelDelta](#domevent-getwheeldelta))
|
||||||
// mean a change of one full zoom level. Smaller values will make wheel-zooming
|
// mean a change of one full zoom level. Smaller values will make wheel-zooming
|
||||||
// faster (and vice versa).
|
// faster (and vice versa).
|
||||||
wheelPxPerZoomLevel: 50
|
wheelPxPerZoomLevel: 60
|
||||||
});
|
});
|
||||||
|
|
||||||
L.Map.ScrollWheelZoom = L.Handler.extend({
|
L.Map.ScrollWheelZoom = L.Handler.extend({
|
||||||
|
Loading…
Reference in New Issue
Block a user