Skip to content
Source
Sign inSign up
TanStack/virtual

fix(virtual-core): honor resize veto for end anchoring #1365

Opendavidfant(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/1365/headopened

Showing 4 changed files with 33 additions and 22 deletions (loading 1).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/resize-ownership-veto.mdAdded
View file
@@ -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.
10 additions and 4 deletionsdocs/api/virtualizer.mdModified
View file
@@ -581,10 +581,10 @@
### `shouldAdjustScrollPositionOnItemSizeChange`
​
```tsx
-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.
​
This is a virtualizer instance property, not a `VirtualizerOptions` option. Assign it directly on the virtualizer instance after creating the virtualizer:
​
@@ -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.