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 2b64b26 commit c7b6658
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/core/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ export const createVirtualStore = (
return computeRange(cache, offset, _prevRange[0], viewportSize);
};
const getTotalSize = (): number => computeTotalSize(cache);
const getScrollableSize = (): number =>
getTotalSize() + startSpacerSize + endSpacerSize;
const getMaxScrollOffset = (): number =>
// total size can become smaller than viewport size
max(0, getScrollableSize() - viewportSize);
max(0, getTotalSize() + startSpacerSize + endSpacerSize - viewportSize);
const getItemOffset = (index: number): number => {
return computeStartOffset(cache, index) - pendingJump;
};
Expand Down Expand Up @@ -259,7 +257,7 @@ export const createVirtualStore = (
const flushedIsJumpByShift = isJumpByShift;
jump = 0;
isJumpByShift = false;
if (viewportSize > getScrollableSize()) {
if (viewportSize > getTotalSize() + startSpacerSize + endSpacerSize) {
// In this case applying jump will not cause scroll.
// Current logic expects scroll event occurs after applying jump so discard it.
return [0, false];
Expand Down

0 comments on commit c7b6658

Please sign in to comment.