virtua 0.41.1 → 0.41.3

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.
@@ -27,12 +27,11 @@ const microtask = typeof queueMicrotask === "function"
27
27
  * @internal
28
28
  */
29
29
  const once = (fn) => {
30
- let called;
31
30
  let cache;
32
31
  return () => {
33
- if (!called) {
34
- called = true;
32
+ if (fn) {
35
33
  cache = fn();
34
+ fn = undefined;
36
35
  }
37
36
  return cache;
38
37
  };
@@ -1357,11 +1356,6 @@ const Virtualizer = (props) => {
1357
1356
  scroller.$dispose();
1358
1357
  });
1359
1358
  });
1360
- createComputed(on(() => props.data.length, (count) => {
1361
- if (count !== store.$getItemsLength()) {
1362
- store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);
1363
- }
1364
- }));
1365
1359
  createComputed(on(() => props.startMargin || 0, (value) => {
1366
1360
  if (value !== store.$getStartSpacerSize()) {
1367
1361
  store.$update(ACTION_START_OFFSET_CHANGE, value);
@@ -1371,6 +1365,12 @@ const Virtualizer = (props) => {
1371
1365
  scroller.$fixScrollJump();
1372
1366
  }));
1373
1367
  const dataSlice = createMemo(() => {
1368
+ const count = props.data.length;
1369
+ untrack(() => {
1370
+ if (count !== store.$getItemsLength()) {
1371
+ store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);
1372
+ }
1373
+ });
1374
1374
  const [start, end] = range();
1375
1375
  const items = end >= 0 ? props.data.slice(start, end + 1) : [];
1376
1376
  const indexes = items.map((_, index) => start + index);
@@ -1527,15 +1527,16 @@ const WindowVirtualizer = (props) => {
1527
1527
  scroller.$dispose();
1528
1528
  });
1529
1529
  });
1530
- createComputed(on(() => props.data.length, (len) => {
1531
- if (len !== store.$getItemsLength()) {
1532
- store.$update(ACTION_ITEMS_LENGTH_CHANGE, [len, props.shift]);
1533
- }
1534
- }));
1535
1530
  createEffect(on(stateVersion, () => {
1536
1531
  scroller.$fixScrollJump();
1537
1532
  }));
1538
1533
  const dataSlice = createMemo(() => {
1534
+ const count = props.data.length;
1535
+ untrack(() => {
1536
+ if (count !== store.$getItemsLength()) {
1537
+ store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);
1538
+ }
1539
+ });
1539
1540
  const [start, end] = range();
1540
1541
  return end >= 0 ? props.data.slice(start, end + 1) : [];
1541
1542
  });