Skip to content

Commit

Permalink
fix: Control sensitivity of the zoom while using mouse
Browse files Browse the repository at this point in the history
resolves: #225
  • Loading branch information
surajshetty3416 committed Oct 24, 2024
1 parent 01dce18 commit 24ed39b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions frontend/src/utils/panAndZoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@ function setPanAndZoom(
};
panAndZoomAreaElement.addEventListener("mousemove", clearPinchPoint, { once: true });
}
// Multiplying with 0.01 to make the zooming less sensitive

let sensitivity = 0.008;
function tooMuchScroll() {
if (e.deltaY > 30 || e.deltaY < -30) {
return true;
}
}
if (tooMuchScroll()) {
// If the user scrolls too much, reduce the sensitivity
// this mostly happens when the user uses mouse wheel to scroll
// probably not the best way to handle this, but works for now
sensitivity = 0.001;
}

// Multiplying with scale to make the zooming feel consistent
let scale = props.scale - e.deltaY * 0.008 * props.scale;
let scale = props.scale - e.deltaY * sensitivity * props.scale;
scale = Math.min(Math.max(scale, zoomLimits.min), zoomLimits.max);
props.scale = scale;
nextTick(() => {
Expand Down

0 comments on commit 24ed39b

Please sign in to comment.