mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-26 12:35:11 +01:00
fix: Scrolling to zoom in embedded map causes containing page to scroll (#376)
This commit is contained in:
parent
4bef77d54b
commit
18b4b0b220
@ -78,7 +78,7 @@ export class FreeFlightControls {
|
|||||||
this.target.addEventListener("contextmenu", this.onContextMenu);
|
this.target.addEventListener("contextmenu", this.onContextMenu);
|
||||||
this.target.addEventListener("mousedown", this.onMouseDown);
|
this.target.addEventListener("mousedown", this.onMouseDown);
|
||||||
this.target.addEventListener("mouseup", this.onMouseUp);
|
this.target.addEventListener("mouseup", this.onMouseUp);
|
||||||
window.addEventListener("wheel", this.onWheel, {passive: true});
|
window.addEventListener("wheel", this.onWheel, {passive: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
@ -134,6 +134,8 @@ export class FreeFlightControls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onWheel = evt => {
|
onWheel = evt => {
|
||||||
|
evt.preventDefault();
|
||||||
|
|
||||||
let delta = evt.deltaY;
|
let delta = evt.deltaY;
|
||||||
if (evt.deltaMode === WheelEvent.DOM_DELTA_PIXEL) delta *= 0.01;
|
if (evt.deltaMode === WheelEvent.DOM_DELTA_PIXEL) delta *= 0.01;
|
||||||
if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE) delta *= 0.33;
|
if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE) delta *= 0.33;
|
||||||
|
@ -48,7 +48,7 @@ export class MouseZoomControls {
|
|||||||
start(manager) {
|
start(manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
|
||||||
this.target.addEventListener("wheel", this.onMouseWheel, {passive: true});
|
this.target.addEventListener("wheel", this.onMouseWheel, {passive: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
@ -82,6 +82,8 @@ export class MouseZoomControls {
|
|||||||
* @param evt {WheelEvent}
|
* @param evt {WheelEvent}
|
||||||
*/
|
*/
|
||||||
onMouseWheel = evt => {
|
onMouseWheel = evt => {
|
||||||
|
evt.preventDefault();
|
||||||
|
|
||||||
let delta = evt.deltaY;
|
let delta = evt.deltaY;
|
||||||
if (evt.deltaMode === WheelEvent.DOM_DELTA_PIXEL) delta *= 0.01;
|
if (evt.deltaMode === WheelEvent.DOM_DELTA_PIXEL) delta *= 0.01;
|
||||||
if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE) delta *= 0.33;
|
if (evt.deltaMode === WheelEvent.DOM_DELTA_LINE) delta *= 0.33;
|
||||||
|
Loading…
Reference in New Issue
Block a user