fix(virtual-core): honor resize veto for end anchoring #1365
Open
davidfant(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/1365/head·opened Showing 4 changed files with 33 additions and 22 deletions (loading 1).
x
@@ -0,0 +1,5 @@
+---
+'@tanstack/virtual-core': patch
+---
+
+Honor explicit false from shouldAdjustScrollPositionOnItemSizeChange during end-anchor resize correction, and let undefined retain the complete default policy.
@@ -581,10 +581,10 @@
-shouldAdjustScrollPositionOnItemSizeChange: undefined | ((item: VirtualItem, delta: number, instance: Virtualizer<TScrollElement, TItemElement>) => boolean)
+shouldAdjustScrollPositionOnItemSizeChange: undefined | ((item: VirtualItem, delta: number, instance: Virtualizer<TScrollElement, TItemElement>) => boolean | undefined)
-Provides fine-grained control over the scroll-position adjustment that fires when an above-viewport item's measured size differs from its estimated size. By default the virtualizer applies this correction only when the user is **not** scrolling backward, which avoids the well-known "items jump while scrolling up" jank. Supply this callback only if you want to override that default — for example, to apply corrections during backward scroll, or to skip them in additional scenarios.
+Controls scroll-position corrections when an item's measured size changes. By default, end anchoring follows changes in the total layout size. Otherwise, first measurements above the viewport are compensated regardless of scroll direction; remeasured items are compensated only when entirely above the viewport and the user is not scrolling backward.
@@ -598,9 +598,15 @@
-The callback receives the resized `item`, the size `delta`, and the `instance`; return `true` to apply the scroll adjustment, `false` to skip it.
+The callback receives the resized `item`, the size `delta`, and the `instance`:
-On iOS WebKit, scroll-position writes are deferred regardless of this callback while a finger is on screen, during momentum-scroll, and during elastic-overscroll bounce. The cumulative delta is flushed in a single write once the scroll settles, preserving iOS's native momentum physics.