aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/app.js b/src/app.js
index 5d7d22b..52adce4 100644
--- a/src/app.js
+++ b/src/app.js
@@ -6428,9 +6428,18 @@ if (INTENT_URI) {
if (e.timeStamp < smoothUntil || matchMedia('(pointer: coarse)').matches || !inScope(e.target)) return;
e.preventDefault();
const px = e.deltaMode === 1 ? e.deltaY * 40 : e.deltaY;
- // reverse turns brake first; same-way turns add to the coast already going
- const keep = Math.sign(v) === Math.sign(px) ? v : 0;
- coast(keep + (px * 3) / TAU);
+ // A reversal catches the old coast immediately. Discard its fractional
+ // step and frame clock too: after a busy frame, applying the NEW velocity
+ // to the OLD elapsed time made the first reverse step jump. Give the
+ // first notch a small response now, then coast the remaining distance.
+ if (v && px && Math.sign(v) !== Math.sign(px)) {
+ stop();
+ const first = Math.sign(px) * Math.min(16, Math.abs(px * 3 / TAU) * 16);
+ window.scrollBy({ top: first, behavior: 'instant' });
+ coast((px * 3 - first) / TAU);
+ } else {
+ coast(v + (px * 3) / TAU);
+ }
}, { passive: false });
// anything else that moves the page takes over from a coast
window.addEventListener('keydown', (e) => { if (/^(Arrow|Page|Home|End| )/.test(e.key)) stop(); });