iterate.com / ui

git clone https://git.iterate.com/repos/ui

Virtual log: a page that lands keeps the row nearest the view's middle still

The correction took the first row of the view that was still there. A page that
lands can also change rows in the view (a fold that takes older events in, a row
that hides), and then every row under such a row moved: 1,263 px once on the
Dash's feed, 28 Nov 2026, 0.4 s after the reader left the list's end. Now the
surviving row that began nearest the view's middle is the one that stands still.
The browser harness: 0 jumps in its 10 scenarios, as before.

Session: claude e7bfeefe-1067-494b-8f63-82177cb1beb9 on beelink

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158EjAGDfCugWqZ9a2JTTgL

Jonas Templestein, 2026-11-28 16:55 UTC · 90a49804ef0453ec39086b101784da27ab720257 · parent 59d04eb

1 file changed

M src/components/virtual-log/virtual-log.tsx
@@ -668,14 +668,25 @@
   const candidates = offsetCandidates.size > 0 ? offsetCandidates : anyCandidates;
   if (candidates.size === 0) return null;
   instance.getTotalSize();
+  // THE ROW THAT THE READER LOOKS AT STANDS STILL: of the rows that are still there, the one that
+  // began nearest the view's middle. A page that lands can also change rows in the view (a fold
+  // that takes older events in, a row that hides): held by the first row of the view, everything
+  // under such a row moved (the Dash's feed, 28 Nov 2026: 1,263 px, 0.4 s after the reader left
+  // the list's end).
+  const middle = liveTop + (instance.scrollRect?.height ?? 0) / 2;
+  let delta: number | null = null;
+  let nearest = Infinity;
   for (let i = 0; i < rows.length; i += 1) {
     const oldStart = candidates.get(rowInfo.key(rows[i]!));
     if (oldStart === undefined) continue;
     const nextItem = instance.measurementsCache[i];
     if (!nextItem) continue;
-    return nextItem.start - oldStart;
+    const distance = Math.abs(oldStart - middle);
+    if (distance >= nearest) continue;
+    nearest = distance;
+    delta = nextItem.start - oldStart;
   }
-  return null;
+  return delta;
 }
 
 /** Matches `@tanstack/virtual-core`'s iOS WebKit check so we never write `scrollTop` during an