diff options
| author | Adam Soltys <[email protected]> | 2026-10-09 00:51:19 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-09 00:51:19 -0700 |
| commit | 2d13695021c80892af3604907a8501cc5d42e443 (patch) | |
| tree | 8d0773e0bbf3390fcae6f39878af36ef11e3789c /src | |
| parent | 806337899029f08bd71fc27be5537e7cc4d590ce (diff) | |
| download | coinosv3-2d13695021c80892af3604907a8501cc5d42e443.tar.gz coinosv3-2d13695021c80892af3604907a8501cc5d42e443.zip | |
Reuse feed overscan to reduce rendering during scroll coasts
Diffstat (limited to 'src')
| -rw-r--r-- | src/features/messages.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index 540f942..d3c8e87 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -6595,18 +6595,27 @@ export function messagesFeature(ctx) { } return changed; } - // On scroll: when the window should move, repaint with the reader's row - // held still. One frame at a time. + // On scroll: replenish the buffer before the reader reaches its edge, + // holding their row still. Coalesce scroll events into one check per frame. let windowRaf = 0; function windowScrolled(c) { if (!c || !c.win || windowRaf) return; windowRaf = requestAnimationFrame(() => { windowRaf = 0; - measureNow(c); const list = c.winList ? c.winList() : null; - if (!list) return; - const next = listWindow(c, list); - if (next.start !== c.win.start || next.end !== c.win.end) holdScroll(render); + if (!list || !c.win || (!c.win.start && c.win.end >= list.length)) return; + // Keep using the 2.5-screen overscan until only one screen remains. + // Recentring it every time an offscreen row crossed the ideal boundary + // rebuilt the whole pane repeatedly during a coast. Two edge reads + // suffice here; measure all rows only when the window actually moves. + const rows = document.querySelectorAll('.notes-feed > .row[data-key]'); + const first = rows[0], last = rows[rows.length - 1], H = window.innerHeight; + if (!first || !last) return; + const nearTop = c.win.start > 0 && first.getBoundingClientRect().top > -H; + const nearBottom = c.win.end < list.length && last.getBoundingClientRect().bottom < 2 * H; + if (!nearTop && !nearBottom) return; + measureNow(c); + holdScroll(render, c); }); } |
