Skip to content

Commit b3b7e7d

Browse files
authored
Adapt default logic to adjust scroll position only on backward scrolling (#1002)
1 parent 152bc3b commit b3b7e7d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/gorgeous-tomatoes-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/virtual-core': patch
3+
---
4+
5+
fix(virtual-core): Adapt default logic to adjust scroll position only on backward scrolling

packages/virtual-core/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,8 @@ export class Virtualizer<
814814
if (
815815
this.shouldAdjustScrollPositionOnItemSizeChange !== undefined
816816
? this.shouldAdjustScrollPositionOnItemSizeChange(item, delta, this)
817-
: item.start < this.getScrollOffset() + this.scrollAdjustments
817+
: this.scrollDirection === 'backward' &&
818+
item.start < this.getScrollOffset() + this.scrollAdjustments
818819
) {
819820
if (process.env.NODE_ENV !== 'production' && this.options.debug) {
820821
console.info('correction', delta)

0 commit comments

Comments
 (0)