virtua 0.47.0 → 0.47.1

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.
@@ -305,6 +305,7 @@ const createVirtualStore = (elementsCount, itemSize = 40, ssrCount = 0, cacheSna
305
305
  let _frozenRange = NULL;
306
306
  let _prevRange = [0, isSSR ? max(ssrCount - 1, 0) : -1];
307
307
  let _totalMeasuredSize = 0;
308
+ let _isViewportMeasured = false;
308
309
  const cache = initCache(elementsCount, cacheSnapshot
309
310
  ? cacheSnapshot[1]
310
311
  : itemSize, cacheSnapshot && cacheSnapshot[0]);
@@ -348,10 +349,10 @@ const createVirtualStore = (elementsCount, itemSize = 40, ssrCount = 0, cacheSna
348
349
  return takeCacheSnapshot(cache);
349
350
  },
350
351
  $getRange: (bufferSize = 200) => {
351
- if (!viewportSize || isSSR) {
352
- // Empty viewportSize means the first render.
353
- // We return range for SSR here, or return [0, -1] to render nothing, until the scroll offset and viewport size are determined.
352
+ if (!_isViewportMeasured || isSSR) {
353
+ // Return range for SSR, or return [0, -1] to render nothing, until the scroll offset and viewport size are determined.
354
354
  // https://github.com/inokawa/virtua/issues/415
355
+ // https://github.com/inokawa/virtua/pull/818
355
356
  return _prevRange;
356
357
  }
357
358
  let startIndex;
@@ -523,7 +524,7 @@ const createVirtualStore = (elementsCount, itemSize = 40, ssrCount = 0, cacheSna
523
524
  case ACTION_VIEWPORT_RESIZE: {
524
525
  if (viewportSize !== payload) {
525
526
  if (!viewportSize) {
526
- shouldSync = true;
527
+ _isViewportMeasured = shouldSync = true;
527
528
  }
528
529
  viewportSize = payload;
529
530
  mutated = UPDATE_VIRTUAL_STATE + UPDATE_SIZE_EVENT;