mirror of
https://github.com/placeAtlas/atlas.git
synced 2025-01-14 15:57:13 +01:00
Merge pull request #853 from TrevorSayre/pixel-scrolling
This commit is contained in:
commit
16267a7562
1 changed files with 16 additions and 7 deletions
|
@ -272,13 +272,22 @@ async function init(){
|
||||||
|
|
||||||
lastPosition = [x, y];
|
lastPosition = [x, y];
|
||||||
|
|
||||||
if(e.deltaY > 0){
|
// Check if we are zooming by pixels
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
|
||||||
|
if (e.deltaMode === 0) {
|
||||||
|
// Scale the pixel delta by the current zoom factor
|
||||||
|
// We want to zoom faster when closer, and slower when further
|
||||||
|
// This creates a smoother experience
|
||||||
|
zoom -= e.deltaY * (0.001 * zoom);
|
||||||
|
} else {
|
||||||
|
if(e.deltaY > 0){
|
||||||
|
|
||||||
zoom = zoom / 2;
|
zoom = zoom / 2;
|
||||||
|
|
||||||
} else if(e.deltaY < 0){
|
} else if(e.deltaY < 0){
|
||||||
|
|
||||||
zoom = zoom * 2;
|
zoom = zoom * 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zoom = Math.max(minZoom, Math.min(maxZoom, zoom));
|
zoom = Math.max(minZoom, Math.min(maxZoom, zoom));
|
||||||
|
|
Loading…
Reference in a new issue