Skip to content

Commit 24ed39b

Browse files
fix: Control sensitivity of the zoom while using mouse
resolves: #225
1 parent 01dce18 commit 24ed39b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

frontend/src/utils/panAndZoom.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,22 @@ function setPanAndZoom(
3434
};
3535
panAndZoomAreaElement.addEventListener("mousemove", clearPinchPoint, { once: true });
3636
}
37-
// Multiplying with 0.01 to make the zooming less sensitive
37+
38+
let sensitivity = 0.008;
39+
function tooMuchScroll() {
40+
if (e.deltaY > 30 || e.deltaY < -30) {
41+
return true;
42+
}
43+
}
44+
if (tooMuchScroll()) {
45+
// If the user scrolls too much, reduce the sensitivity
46+
// this mostly happens when the user uses mouse wheel to scroll
47+
// probably not the best way to handle this, but works for now
48+
sensitivity = 0.001;
49+
}
50+
3851
// Multiplying with scale to make the zooming feel consistent
39-
let scale = props.scale - e.deltaY * 0.008 * props.scale;
52+
let scale = props.scale - e.deltaY * sensitivity * props.scale;
4053
scale = Math.min(Math.max(scale, zoomLimits.min), zoomLimits.max);
4154
props.scale = scale;
4255
nextTick(() => {

0 commit comments

Comments
 (0)