aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-09 01:06:37 -0700
committerAdam Soltys <[email protected]>2026-10-09 01:06:37 -0700
commit817bcc3ba7b2aaad388bc5b2e5cda5ccf7b27766 (patch)
treedcee40a6ed25e6b7e8a1f0dcfa180aca9db05f97 /src/app.js
parent537b116400089ce15a1bdbeb0873cb88dfa35fe3 (diff)
downloadcoinosv3-817bcc3ba7b2aaad388bc5b2e5cda5ccf7b27766.tar.gz
coinosv3-817bcc3ba7b2aaad388bc5b2e5cda5ccf7b27766.zip
Restart wheel coast timing and respond immediately on reversal
Diffstat (limited to 'src/app.js')
-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(); });