Skip to content
Source
Sign inSign up
TanStack/virtual

fix(virtual-core): leave resizes measured before a scroll command's read-back to reconcile #1309

Mergedpiecykmerged 3 commits intomain fromrefs/pull/1309/headmerged by piecyk

Showing 4 changed files with 51 additions and 7 deletions (loading 2).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/last-written-scroll-offset.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/virtual-core': patch
+---
+​
+fix(virtual-core): leave resizes measured before a scroll command's write is read back to reconcile, so an upward `scrollToIndex` no longer jumps back and stalls until the safety valve, and build `scrollBy` on a just-written offset
46 additions and 7 deletionspackages/virtual-core/src/index.tsModified
View file
@@ -406,6 +406,14 @@
stableFrames: number
// Keep arrival across measurement-driven retargets so external scrolls can cancel.
hasReachedTarget: boolean
+​
+ // Where our last non-smooth write for this command put the element, until
+ // its scroll event arrives. Until then `scrollOffset` still holds the old
+ // position, and the rows on screen are the ones rendered for it. A smooth
+ // write leaves it null: the element is somewhere between the two offsets.
+ // It goes with the scroll state, so a write the browser ignored (no read-back)
+ // does not outlive its command.
+ writtenOffset?: number | null
​
type PendingScrollAnchor = [
@@ -973,6 +981,7 @@