diff --git a/docker/frontend/src/Library.tsx b/docker/frontend/src/Library.tsx index d88d0cd..fff2e1a 100644 --- a/docker/frontend/src/Library.tsx +++ b/docker/frontend/src/Library.tsx @@ -3070,6 +3070,12 @@ function useWallWindow(count: number, on: boolean): { ref: RefObject void>(() => {}); + // The step from one row to the next, taken once per column count and kept. It + // is a ref rather than a value read on every pass because the pass reads it off + // the rows the window drew — and a step that moves with the window is a window + // that moves with the step: the two trade places forever (see `measure`). + const pitchRef = useRef(0); + const colsRef = useRef(0); // The window over a scroll container is taken rather than kept, so it is taken // after every render: the first pass draws a screenful, the next reads the row's // step off it and lays out the spacers, and the pass after that leaves both @@ -3108,7 +3114,23 @@ function useWallWindow(count: number, on: boolean): { ref: RefObject 0) { + colsRef.current = cols; + pitchRef.current = drawn; + } + } + const pitch = pitchRef.current; if (!(pitch > 0)) return; const rows = Math.ceil(count / cols); const row0 = Math.max(0, Math.floor(el.scrollTop / pitch) - WALL_ROWS);