diff --git a/public/assets/pages/viewerpage/application_image/zoom.js b/public/assets/pages/viewerpage/application_image/zoom.js index 59dec6da..b2aa78c5 100644 --- a/public/assets/pages/viewerpage/application_image/zoom.js +++ b/public/assets/pages/viewerpage/application_image/zoom.js @@ -22,7 +22,7 @@ export default function ({ $img, $page }) { state.y = 0; } state.scale = next; - state.duration = duration ?? (next === 1 ? 500 : 200); + state.duration = duration ?? (next === 1 ? 500 : 150); return state; }, { scale: 1, x: 0, y: 0, duration: 0 }), rxjs.tap(({ scale, x, y, duration }) => { @@ -46,8 +46,17 @@ function builder({ $img }) { // zoom via scroll wheel rxjs.fromEvent($img.parentElement, "wheel").pipe( rxjs.tap((e) => e.preventDefault()), - rxjs.throttleTime(100, rxjs.animateFrameScheduler), - rxjs.map((e) => ({ scale: Math.min(Math.exp(-e.deltaY / 300), 2), clientX: e.clientX, clientY: e.clientY })), + rxjs.bufferTime(100), + rxjs.filter(events => events.length > 0), + rxjs.map((events) => { + let out = null; + for (let i=0; i Math.abs(out.scale)) out = ({ scale, clientX: events[i].clientX, clientY: events[i].clientY }); + } + return out; + }), ), // zoom via keyboard shortcut rxjs.fromEvent(window, "keydown").pipe(