diff --git a/src/core/store.ts b/src/core/store.ts index f521f35b..01103a18 100644 --- a/src/core/store.ts +++ b/src/core/store.ts @@ -350,19 +350,13 @@ 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 @@ -370,7 +364,7 @@ export const createVirtualStore = ( applyJump( updated.reduce((acc, [index, size]) => { if ( - !shouldKeepStart || + shouldStickToEnd || (_frozenRange ? // https://github.com/inokawa/virtua/issues/380 index < _frozenRange[0]