fix scroll jank

This commit is contained in:
biglyderv 2024-10-17 16:07:30 -04:00
parent df956c6061
commit b6c550d957

View file

@ -21,6 +21,7 @@ let center = [0, 0];
let lastPos = [0, 0];
let isMouse = false;
let zoom = 1;
let timer = 0;
let id = '';
@ -69,16 +70,26 @@ function mouseDown(e) {
}
function wheel(e) {
document.body.style.overflow = 'hidden';
if (timer != 0) clearTimeout(timer);
timer = setTimeout(function() {
document.body.style.overflow = '';
},400)
mpos[0] -= lastPos[0];
mpos[1] -= lastPos[1];
mpos[0] *= (1.005 ** -e.deltaY)
mpos[1] *= (1.005 ** -e.deltaY)
let f = (2 ** -(e.deltaY/256));
mpos[0] *= f;
mpos[1] *= f;
mpos[0] += lastPos[0];
mpos[1] += lastPos[1];
zoom *= (1.005 ** -e.deltaY)
zoom *= f;
}
function move() {