From 5a71aaa4855c7f619a8ff9522754ce22393817a5 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 16 Oct 2026 20:24:22 -0700 Subject: The wheel coasts over a video and on a thread, and a turn back against a coast is a gentler half push that winds up again from the next notch. A notch with the pointer over a clip fell to the browser's single-notch scroll: video and audio were on the wheel handler's hands-off list from the first commit, though the wheel does nothing to a player itself. The thread page was outside the handler's scope altogether, so a thread scrolled plain while the feed coasted. Both coast now, like the words around them (Adam, 2026-10-16). A reversal was a full notch the other way followed by two notches without wind-up, and felt like an overshoot. It is now half a notch's travel at half the speed, so the reader who flew past a post settles back onto it; the next notch the same way is a plain one, winding up from whatever speed the half push left, so a spin on after a reversal gets going at once. (The five-notch quarter-size hunt stays gone.) feed-wheel-reverse-test: the half push, the wind-up from the second notch, a notch over a video / audio / a thread coasts, one in a text box or the pager does not; the fixture's target can sit inside a given element and on a thread page. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01J1Kon8bxJoHRpJdSzshCkp --- src/app.js | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/app.js') diff --git a/src/app.js b/src/app.js index dae7b17..96c6af1 100644 --- a/src/app.js +++ b/src/app.js @@ -6617,13 +6617,17 @@ if (INTENT_URI) { // selection, and a drag that moved isn't a click on what it started on. (() => { if (typeof window === 'undefined' || matchMedia('(prefers-reduced-motion: reduce)').matches) return; - const SCOPE = '.feed-page, .notes-feed'; + const SCOPE = '.feed-page, .notes-feed, .thread-page'; // a thread scrolls the same as a feed (Adam, 2026-10-16) const TAU = 325; // ms: how quickly a coast dies down (the phone's feel) const VMAX = 16; // px/ms const inScope = (t) => { const el = t && t.closest ? t : t && t.parentElement; if (!el || !el.closest(SCOPE)) return false; - if (el.closest('input, textarea, select, video, audio, [contenteditable], .feed-chips, .lightbox, .media-pager')) return false; + // (A video or an audio player is part of the feed: a notch over a clip + // coasts like one over the words — the wheel does nothing to a player + // itself, so there is nothing to leave it. Adam, 2026-10-16: "over a + // video it doesn't initiate a coast, just a single notch".) + if (el.closest('input, textarea, select, [contenteditable], .feed-chips, .lightbox, .media-pager')) return false; // something inside that scrolls on its own (a caption, a list) keeps its wheel for (let n = el; n && n !== document.body; n = n.parentElement) { if (n.scrollHeight > n.clientHeight + 1 && /(auto|scroll)/.test(getComputedStyle(n).overflowY)) return false; @@ -6653,16 +6657,19 @@ if (INTENT_URI) { if (!raf && v) { last = performance.now(); raf = requestAnimationFrame(tick); } }; // ---- the wheel - // A turn back against the coast catches the page at once and is a plain - // notch from rest — no flight the other way, since the next couple of - // notches after a reversal (CALM) don't wind the speed up, so a couple of - // correcting notches travel a couple of notches; a spin that keeps going - // winds up again from the third. (A spell of quarter-size "hunting" - // notches ramping back up was tried here and felt like a stutter and a - // slow patch; a 700 ms spell without wind-up after a reversal was tried - // too and a spin begun inside it felt slow — Adam, 2026-10-16.) - const CALM = 2; // notches after a reversal without wind-up - let calmLeft = 0; // (lastDir/lastMoveAt: the tick's, above) + // A turn back against the coast catches the page at once and is a gentler + // push the other way — half a notch's travel, at half the speed — so the + // reader who overshot a post settles back onto it instead of flying past + // it the other way. The next notch the same way is a plain one, winding + // up from whatever speed the half push left, so a spin on after a + // reversal gets going again at once. (A spell of quarter-size "hunting" + // notches ramping back up over five turns was tried here and felt like a + // stutter and a slow patch; a full notch then two without wind-up felt + // like an overshoot — Adam, 2026-10-16: "could the first coast in the + // opposite direction be smaller/slower than usual? then speed up if we + // scroll again in the same direction".) + const REVERSE = 0.5; // of a notch: the first push back against a coast + // (lastDir/lastMoveAt: the tick's, above) let smoothUntil = 0; // a trackpad's events were just seen: hands off window.addEventListener('wheel', (e) => { if (e.ctrlKey || e.shiftKey || e.defaultPrevented) return; @@ -6680,19 +6687,19 @@ if (INTENT_URI) { // 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 - // notch a small response now, then coast the rest of its travel. + // notch a small response now, then coast the rest of its (half) travel. stop(); - calmLeft = CALM; - const first = dir * Math.min(16, Math.abs(px * 3 / TAU) * 16); + const travel = px * 3 * REVERSE; + const first = dir * Math.min(16, Math.abs(travel / TAU) * 16); window.scrollBy({ top: first, behavior: 'instant' }); lastDir = dir; lastMoveAt = now; - coast((px * 3 - first) / TAU, TAU); + coast((travel - first) / TAU, TAU); } else { // A notch into a page already moving pushes harder: the faster it // goes, the more each turn adds (up to 2.5x), so keeping the wheel // turning winds the speed up instead of settling at a stroll. From // rest a notch is the same push as ever. - const gain = calmLeft-- > 0 ? 1 : 1 + Math.min(1.5, Math.abs(v) / 4); + const gain = 1 + Math.min(1.5, Math.abs(v) / 4); coast(v + (px * 3 * gain) / TAU, TAU); } }, { passive: false }); -- cgit v1.2.3