diff options
| -rw-r--r-- | src/app.js | 20 | ||||
| -rw-r--r-- | tools/feed-wheel-reverse-test.js | 11 |
2 files changed, 21 insertions, 10 deletions
@@ -6654,13 +6654,15 @@ if (INTENT_URI) { }; // ---- 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 for a moment after a - // reversal (CALM) notches don't wind the speed up, so a couple of - // correcting notches travel a couple of notches. (A spell of quarter-size - // "hunting" notches ramping back up was tried here and felt like a - // stutter and a slow patch — Adam, 2026-10-16.) - const CALM = 700; // ms after a reversal without wind-up - let calmUntil = 0; // (lastDir/lastMoveAt: the tick's, above) + // 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) 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,7 +6682,7 @@ if (INTENT_URI) { // 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. stop(); - calmUntil = now + CALM; + calmLeft = CALM; const first = dir * Math.min(16, Math.abs(px * 3 / TAU) * 16); window.scrollBy({ top: first, behavior: 'instant' }); lastDir = dir; lastMoveAt = now; @@ -6690,7 +6692,7 @@ if (INTENT_URI) { // 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 = now < calmUntil ? 1 : 1 + Math.min(1.5, Math.abs(v) / 4); + const gain = calmLeft-- > 0 ? 1 : 1 + Math.min(1.5, Math.abs(v) / 4); coast(v + (px * 3 * gain) / TAU, TAU); } }, { passive: false }); diff --git a/tools/feed-wheel-reverse-test.js b/tools/feed-wheel-reverse-test.js index 1f133ff..632bbc6 100644 --- a/tools/feed-wheel-reverse-test.js +++ b/tools/feed-wheel-reverse-test.js @@ -57,9 +57,18 @@ for (const dir of [1, -1]) { assert(calm > 540 && calm < 700, 'a reversal and a quick second notch: about two notches of travel: ' + calm); } // From rest, well after, the wind-up is back: the same two quick notches go further. { f.advance(2500); const y = f.y; f.wheel(dir); f.advance(60); f.frame(); f.wheel(dir); settle(f); const s = (f.y - y) * dir; assert(s > calm + 40, 'two quick notches with the wind-up go further: ' + s + ' vs ' + calm); } + // A spin that keeps going after a reversal winds up again from its third + // notch: a reversal plus four quick notches goes well past five plain ones. + let spin; + { f.wheel(-dir); f.advance(17); f.frame(); f.wheel(-dir); f.advance(120); f.frame(); + const y = f.y; f.wheel(dir); for (let i = 0; i < 4; i++) { f.advance(60); f.frame(); f.wheel(dir); } settle(f); spin = (f.y - y) * dir; + assert(spin > 5 * 300 + 150, 'a spin on after a reversal winds up again: ' + spin); } + // ...and the same five quick notches from rest go about as far (the two calm ones cost little). + { f.advance(2500); const y = f.y; f.wheel(dir); for (let i = 0; i < 4; i++) { f.advance(60); f.frame(); f.wheel(dir); } settle(f); const s = (f.y - y) * dir; + assert(s < spin * 1.25, 'five from rest vs five after a reversal: ' + s + ' vs ' + spin); settle(f, 200); } // From rest a notch either way is a full push. { f.advance(2500); const y = f.y; f.wheel(dir); settle(f); const s = (f.y - y) * dir; assert(s > 280 && s < 330, 'from rest a notch either way is a full push: ' + s); } // A turn back against a coast that only just died is a reversal too (caught, no wind-up). { f.wheel(dir); settle(f, 40); f.advance(100); const y = f.y; f.wheel(-dir); f.advance(60); f.frame(); f.wheel(-dir); settle(f); const s = (y - f.y) * dir; assert(s > 520 && s < 700, 'reversing right after the coast dies: no wind-up: ' + s); } } -console.log('✓ immediate reversal both ways, stale frame timestamps, busy frame recovery, a reversal is a plain notch with no wind-up for a moment'); +console.log('✓ immediate reversal both ways, stale frame timestamps, busy frame recovery, a reversal is a plain notch, two calm notches, then the wind-up is back'); |
