diff --git a/docker/frontend/src/Library.tsx b/docker/frontend/src/Library.tsx index 635bbe8..68a707b 100644 --- a/docker/frontend/src/Library.tsx +++ b/docker/frontend/src/Library.tsx @@ -4076,13 +4076,13 @@ function useWallWindow(count: number, on: boolean): { ref: RefObject(':scope > .adm-card'); const rowsDrawn = Math.floor(cards.length / cols); - if (rowsDrawn < 2) return; // The step from one row to the next, taken as the drawn run's own average. // The cards do NOT all stand the same height — a caption that wraps makes // its row taller — and `offsetTop` is rounded to whole pixels, so the @@ -4098,15 +4098,31 @@ function useWallWindow(count: number, on: boolean): { ref: RefObject= 2) { const drawn = (cards[(rowsDrawn - 1) * cols].getBoundingClientRect().top - cards[0].getBoundingClientRect().top) / (rowsDrawn - 1); if (drawn > 0) { colsRef.current = cols; pitchRef.current = drawn; } } - const pitch = pitchRef.current; - if (!(pitch > 0)) return; + // And the one-row run, which has no average to take: its own height is the + // step — one card plus the gap, the same fallback the settle effect takes. + // Returning here instead is a window that cannot grow, and there is a shelf + // it strands: the reset above puts a year of four frames at {0, 4}, one row + // of five columns, no average — and every pass after it reads that one row + // and leaves, so the shelf stands at four cards for the rest of the visit; + // another year, another folder, a reset, all four cards under a count of six + // hundred. The step is a guess, and a spacer a few pixels out is a scrollbar + // a few pixels out; a window left alone is the wall. + let pitch = pitchRef.current; + if (!(pitch > 0) || colsRef.current !== cols) { + const first = cards[0]; + if (!first) return; + pitch = first.offsetHeight + WALL_GAP; + if (!(pitch > 0)) return; + colsRef.current = cols; + pitchRef.current = pitch; + } const rows = Math.ceil(count / cols); const row0 = Math.max(0, Math.floor(now.scrollTop / pitch) - WALL_ROWS); const row1 = Math.min(rows, Math.ceil((now.scrollTop + now.clientHeight) / pitch) + WALL_ROWS);