Skip to content
Source
Sign inSign up
TanStack/virtual

fix(virtual-core): use getMaxScrollOffset() - paddingEnd for scrollToIndex(last) end-align #1276

Mergeddikshit-n(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/1276/headmerged by piecyk

Showing 3 changed files with 34 additions and 6 deletions (loading 1).

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/fix-scrolltoindex-paddingend.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/virtual-core': patch
+---
+​
+Fix `scrollToIndex(last, { align: 'end' })` overshooting the last item by `paddingEnd`; it now respects `scrollPaddingEnd` like other end-aligned items. To scroll to the very bottom including `paddingEnd`, use `scrollToEnd()`.
29 additions and 6 deletionspackages/virtual-core/src/index.tsModified
View file
@@ -383,6 +383,8 @@
index: number | null
align: ScrollAlignment
behavior: ScrollBehavior
+ // scrollToEnd: track the DOM max scroll offset instead of the item's offset
+ toEnd?: boolean
​
// lifecycle
startedAt: number
@@ -1168,8 +1170,9 @@
return
- const offsetInfo =
- this.scrollState.index != null