Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed Mar 10, 2024
1 parent c7b6658 commit 6be6a82
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/core/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,27 +350,21 @@ export const createVirtualStore = (
break;
}

let shouldKeepStart = false;
let shouldStickToEnd = false;
if (_scrollMode === SCROLL_BY_SHIFT) {
if (scrollOffset > getMaxScrollOffset() - SUBPIXEL_THRESHOLD) {
// Keep end to stick to the end
shouldStickToEnd = true;
} else {
// Keep distance from end immediately after prepending
// We can assume jumps occurred on the upper outside
}
} else {
// Keep start at mid
shouldKeepStart = true;
if (
_scrollMode === SCROLL_BY_SHIFT &&
scrollOffset > getMaxScrollOffset() - SUBPIXEL_THRESHOLD
) {
// Keep end to stick to the end immediately after prepending
shouldStickToEnd = true;
}

// Calculate jump
// Should maintain visible position to minimize junks in appearance
applyJump(
updated.reduce((acc, [index, size]) => {
if (
!shouldKeepStart ||
shouldStickToEnd ||
(_frozenRange
? // https://github.com/inokawa/virtua/issues/380
index < _frozenRange[0]
Expand Down

0 comments on commit 6be6a82

Please sign in to comment.