DomEvent.js (Leaflet-1.8.0) | : | DomEvent.js (Leaflet-1.9.0) | ||
---|---|---|---|---|
skipping to change at line 227 | skipping to change at line 227 | |||
} | } | |||
// @function stop(ev: DOMEvent): this | // @function stop(ev: DOMEvent): this | |||
// Does `stopPropagation` and `preventDefault` at the same time. | // Does `stopPropagation` and `preventDefault` at the same time. | |||
export function stop(e) { | export function stop(e) { | |||
preventDefault(e); | preventDefault(e); | |||
stopPropagation(e); | stopPropagation(e); | |||
return this; | return this; | |||
} | } | |||
// @function getPropagationPath(ev: DOMEvent): Array | ||||
// Compatibility polyfill for [`Event.composedPath()`](https://developer.mozilla | ||||
.org/en-US/docs/Web/API/Event/composedPath). | ||||
// Returns an array containing the `HTMLElement`s that the given DOM event | ||||
// should propagate to (if not stopped). | ||||
export function getPropagationPath(ev) { | ||||
if (ev.composedPath) { | ||||
return ev.composedPath(); | ||||
} | ||||
var path = []; | ||||
var el = ev.target; | ||||
while (el) { | ||||
path.push(el); | ||||
el = el.parentNode; | ||||
} | ||||
return path; | ||||
} | ||||
// @function getMousePosition(ev: DOMEvent, container?: HTMLElement): Point | // @function getMousePosition(ev: DOMEvent, container?: HTMLElement): Point | |||
// Gets normalized mouse position from a DOM event relative to the | // Gets normalized mouse position from a DOM event relative to the | |||
// `container` (border excluded) or to the whole page if not specified. | // `container` (border excluded) or to the whole page if not specified. | |||
export function getMousePosition(e, container) { | export function getMousePosition(e, container) { | |||
if (!container) { | if (!container) { | |||
return new Point(e.clientX, e.clientY); | return new Point(e.clientX, e.clientY); | |||
} | } | |||
var scale = getScale(container), | var scale = getScale(container), | |||
offset = scale.boundingClientRect; // left and top values are in pag e scale (like the event clientX/Y) | offset = scale.boundingClientRect; // left and top values are in pag e scale (like the event clientX/Y) | |||
return new Point( | return new Point( | |||
// offset.left/top values are in page scale (like clientX/Y), | // offset.left/top values are in page scale (like clientX/Y), | |||
// whereas clientLeft/Top (border width) values are the original values (before CSS scale applies). | // whereas clientLeft/Top (border width) values are the original values (before CSS scale applies). | |||
(e.clientX - offset.left) / scale.x - container.clientLeft, | (e.clientX - offset.left) / scale.x - container.clientLeft, | |||
(e.clientY - offset.top) / scale.y - container.clientTop | (e.clientY - offset.top) / scale.y - container.clientTop | |||
); | ); | |||
} | } | |||
// Chrome on Win scrolls double the pixels as in other platforms (see #4538), | // except , Safari and | |||
// and Firefox scrolls device pixels, not CSS pixels | // We need double the scroll pixels (see #7403 and #4538) for all Browsers | |||
var wheelPxFactor = | // except OSX (Mac) -> 3x, Chrome running on Linux 1x | |||
(Browser.win && Browser.chrome) ? 2 * window.devicePixelRatio : | ||||
Browser.gecko ? window.devicePixelRatio : 1; | ||||
var wheelPxFactor = | ||||
(Browser.linux && Browser.chrome) ? window.devicePixelRatio : | ||||
Browser.mac ? window.devicePixelRatio * 3 : | ||||
window.devicePixelRatio > 0 ? 2 * window.devicePixelRatio : 1; | ||||
// @function getWheelDelta(ev: DOMEvent): Number | // @function getWheelDelta(ev: DOMEvent): Number | |||
// Gets normalized wheel delta from a wheel DOM event, in vertical | // Gets normalized wheel delta from a wheel 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 60 pixels. | // a best guess of 60 pixels. | |||
export function getWheelDelta(e) { | export function getWheelDelta(e) { | |||
return (Browser.edge) ? e.wheelDeltaY / 2 : // Don't trust window-geometr y-based delta | return (Browser.edge) ? e.wheelDeltaY / 2 : // Don't trust window-geometr y-based delta | |||
(e.deltaY && e.deltaMode === 0) ? -e.deltaY / wheelPxFactor : // P ixels | (e.deltaY && e.deltaMode === 0) ? -e.deltaY / wheelPxFactor : // P ixels | |||
(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines | (e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines | |||
(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages | (e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages | |||
End of changes. 3 change blocks. | ||||
5 lines changed or deleted | 27 lines changed or added |