From 2f69e7bd8885a1775a292a1bf2734e0eeb17779b Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Mon, 25 Aug 2025 17:09:36 -0600 Subject: [PATCH] Stop momentum if slow enough. --- src/plugins/scrollManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/scrollManager.js b/src/plugins/scrollManager.js index 73feb77..fa43cdf 100644 --- a/src/plugins/scrollManager.js +++ b/src/plugins/scrollManager.js @@ -96,13 +96,14 @@ function createMomentumDrag({ } catch {} } usingPointerLock = false + velocity = 0 if (samples.length) { const first = samples[0] const now = performance.now() const last = samples[samples.length - 1] const dy = last.position - first.position - velocity = (-dy * speed) / (now - first.timestamp) - } else velocity = 0 + if (Math.abs(dy) > 5) velocity = (-dy * speed) / (now - first.timestamp) + } console.log(velocity, samples) samples = [] startMomentum()