virtua 0.48.7 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -473,21 +473,34 @@ const createVirtualStore = (elementsCount, itemSize = 40, ssrCount = 0, cacheSna
473
473
  }
474
474
  // Calculate jump by resize to minimize junks in appearance
475
475
  applyJump(updated.reduce((acc, [index, size]) => {
476
+ let shouldKeep;
476
477
  if (
477
478
  // Keep distance from end during shifting
478
- _scrollMode === SCROLL_BY_SHIFT ||
479
- (_frozenRange && _scrollMode === SCROLL_BY_MANUAL_SCROLL
480
- ? // https://github.com/inokawa/virtua/issues/380
481
- // https://github.com/inokawa/virtua/issues/758
482
- index < _frozenRange[0]
483
- : // Otherwise we should maintain visible position
484
- getItemOffset$1(
485
- // https://github.com/inokawa/virtua/issues/385
486
- // https://github.com/inokawa/virtua/discussions/865
487
- _scrollDirection !== SCROLL_DOWN &&
488
- _scrollMode === SCROLL_BY_NATIVE
489
- ? index + 1
490
- : index) < getRelativeScrollOffset())) {
479
+ _scrollMode === SCROLL_BY_SHIFT) {
480
+ shouldKeep = true;
481
+ }
482
+ else if (_frozenRange &&
483
+ _scrollMode === SCROLL_BY_MANUAL_SCROLL) {
484
+ // https://github.com/inokawa/virtua/issues/380
485
+ // https://github.com/inokawa/virtua/issues/758
486
+ shouldKeep = index < _frozenRange[0];
487
+ }
488
+ else {
489
+ // Otherwise we should maintain visible position
490
+ const start = getRelativeScrollOffset();
491
+ const itemOffset = getItemOffset$1(index);
492
+ const itemSize = getItemSize$1(index);
493
+ shouldKeep =
494
+ _scrollDirection !== SCROLL_DOWN &&
495
+ _scrollMode === SCROLL_BY_NATIVE
496
+ ? // https://github.com/inokawa/virtua/issues/385
497
+ // https://github.com/inokawa/virtua/discussions/865
498
+ itemOffset + itemSize < start
499
+ : // https://github.com/inokawa/virtua/pull/868
500
+ itemOffset < start &&
501
+ itemOffset + itemSize < start + viewportSize;
502
+ }
503
+ if (shouldKeep) {
491
504
  acc += size - getItemSize$1(index);
492
505
  }
493
506
  return acc;