fix scroll jank
This commit is contained in:
parent
df956c6061
commit
b6c550d957
1 changed files with 14 additions and 3 deletions
|
@ -21,6 +21,7 @@ let center = [0, 0];
|
||||||
let lastPos = [0, 0];
|
let lastPos = [0, 0];
|
||||||
let isMouse = false;
|
let isMouse = false;
|
||||||
let zoom = 1;
|
let zoom = 1;
|
||||||
|
let timer = 0;
|
||||||
|
|
||||||
let id = '';
|
let id = '';
|
||||||
|
|
||||||
|
@ -69,16 +70,26 @@ function mouseDown(e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function wheel(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[0] -= lastPos[0];
|
||||||
mpos[1] -= lastPos[1];
|
mpos[1] -= lastPos[1];
|
||||||
|
|
||||||
mpos[0] *= (1.005 ** -e.deltaY)
|
let f = (2 ** -(e.deltaY/256));
|
||||||
mpos[1] *= (1.005 ** -e.deltaY)
|
|
||||||
|
mpos[0] *= f;
|
||||||
|
mpos[1] *= f;
|
||||||
|
|
||||||
mpos[0] += lastPos[0];
|
mpos[0] += lastPos[0];
|
||||||
mpos[1] += lastPos[1];
|
mpos[1] += lastPos[1];
|
||||||
|
|
||||||
zoom *= (1.005 ** -e.deltaY)
|
zoom *= f;
|
||||||
}
|
}
|
||||||
|
|
||||||
function move() {
|
function move() {
|
||||||
|
|
Loading…
Reference in a new issue