Skip to content
Source
Sign inSign up
TanStack/virtual

fix(virtual-core): stop an iOS fling for a command issued during it #1332

Mergedpiecykmerged 4 commits intomain fromrefs/pull/1332/headmerged by piecyk

Showing 3 changed files with 90 additions and 5 deletions (loading 1).

x
0 of 3 viewed, 3 left
7 additions and 0 deletions.changeset/ios-fling-stop.mdAdded
View file
@@ -0,0 +1,7 @@
+---
+'@tanstack/virtual-core': patch
+---
+​
+fix(virtual-core): on iOS 27 and later, a scroll command issued during a fling takes effect at once
+​
+A `scrollToIndex`, `scrollToOffset` or `scrollToEnd` issued during a fling waited for the fling to end, so a button outside the list (such as "jump to latest") did nothing until the list stopped. The command now stops the fling by hiding the scroll element's overflow for two frames, then restores the element's own inline value and writes. The user taking over before the write still cancels the command.
83 additions and 5 deletionspackages/virtual-core/src/index.tsModified
View file
@@ -995,6 +995,10 @@
this.rafId = null
this.scrollState = null
+ // The element is let go of: give it back its overflow now. A stop the
+ // next element needs starts afresh.
+ this._momentumStop?.restore()
+ this._momentumStop = null
// The debounce cancelled above is the only thing that writes `isScrolling`
// back to false, so a cleanup inside the reset window would strand it, and
// the direction derived from it, as true. That matters because `cleanup`
@@ -2163,6 +2167,60 @@
return null