Skip to content

Commit

Permalink
Throttle mousewheel events
Browse files Browse the repository at this point in the history
  • Loading branch information
ricktu288 committed Dec 25, 2023
1 parent 4bb8128 commit 2b26274
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions simulator/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,14 @@ function canvas_ondblclick(e) {

}

var lastZoomTime = 0;
var zoomThrottle = 100; // 100 ms between zooms

function canvas_onmousewheel(e) {
var now = Date.now();
if (now - lastZoomTime < zoomThrottle) return; // Too soon since the last zoom
lastZoomTime = now;

// cross-browser wheel delta
var e = window.event || e; // old IE support
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
Expand Down

0 comments on commit 2b26274

Please sign in to comment.