Description
On a trackpad or high-resolution mouse wheel, a single swipe or scroll gesture fires many wheel events in rapid succession. Because each event advances the slide, a short scroll can skip several slides at once, making navigation feel uncontrollable.
Current behaviour
src/mdeck/controllers/inputs/mouse.ts emits gotoNextSlide / gotoPreviousSlide on every wheel event with no rate limiting.
Expected behaviour
Scroll-based navigation should advance at most one slide per gesture, using a debounce or cooldown period (e.g. ~400 ms) between slide changes triggered by wheel events.
Suggested implementation
Add a timestamp-based cooldown in the wheel handler:
let lastScroll = 0;
const SCROLL_COOLDOWN_MS = 400;
element.addEventListener('wheel', (e) => {
const now = Date.now();
if (now - lastScroll < SCROLL_COOLDOWN_MS) return;
lastScroll = now;
e.deltaY > 0 ? events.emit('gotoNextSlide') : events.emit('gotoPreviousSlide');
});
Ported from gnab/remark#564
Description
On a trackpad or high-resolution mouse wheel, a single swipe or scroll gesture fires many
wheelevents in rapid succession. Because each event advances the slide, a short scroll can skip several slides at once, making navigation feel uncontrollable.Current behaviour
src/mdeck/controllers/inputs/mouse.tsemitsgotoNextSlide/gotoPreviousSlideon every wheel event with no rate limiting.Expected behaviour
Scroll-based navigation should advance at most one slide per gesture, using a debounce or cooldown period (e.g. ~400 ms) between slide changes triggered by wheel events.
Suggested implementation
Add a timestamp-based cooldown in the wheel handler:
Ported from gnab/remark#564