virtua 0.40.1 → 0.40.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.
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +1 -1
- package/lib/core/index.mjs.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/react/VGrid.d.ts +8 -0
- package/lib/solid/index.js +1 -1
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.jsx +17 -22
- package/lib/solid/index.jsx.map +1 -1
- package/lib/solid/index.mjs +1 -1
- package/lib/solid/index.mjs.map +1 -1
- package/lib/svelte/Virtualizer.svelte +10 -11
- package/lib/svelte/WindowVirtualizer.svelte +10 -11
- package/lib/vue/index.js +1 -1
- package/lib/vue/index.js.map +1 -1
- package/lib/vue/index.mjs +1 -1
- package/lib/vue/index.mjs.map +1 -1
- package/package.json +4 -4
- package/lib/react/useRerender.d.ts +0 -1
package/lib/solid/index.jsx
CHANGED
|
@@ -246,6 +246,7 @@ const isSmoothScrollSupported = /*#__PURE__*/ once(() => {
|
|
|
246
246
|
return "scrollBehavior" in getDocumentElement().style;
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
+
const MAX_INT_32 = 0x7fffffff;
|
|
249
250
|
const SCROLL_IDLE = 0;
|
|
250
251
|
const SCROLL_DOWN = 1;
|
|
251
252
|
const SCROLL_UP = 2;
|
|
@@ -293,11 +294,10 @@ const isInitialMeasurementDone = (store) => {
|
|
|
293
294
|
*/
|
|
294
295
|
const createVirtualStore = (elementsCount, itemSize = 40, overscan = 4, ssrCount = 0, cacheSnapshot, shouldAutoEstimateItemSize = false) => {
|
|
295
296
|
let isSSR = !!ssrCount;
|
|
296
|
-
let stateVersion =
|
|
297
|
+
let stateVersion = 1;
|
|
297
298
|
let viewportSize = 0;
|
|
298
299
|
let startSpacerSize = 0;
|
|
299
300
|
let scrollOffset = 0;
|
|
300
|
-
let jumpCount = 0;
|
|
301
301
|
let jump = 0;
|
|
302
302
|
let pendingJump = 0;
|
|
303
303
|
let _flushedJump = 0;
|
|
@@ -330,7 +330,6 @@ const createVirtualStore = (elementsCount, itemSize = 40, overscan = 4, ssrCount
|
|
|
330
330
|
}
|
|
331
331
|
else {
|
|
332
332
|
jump += j;
|
|
333
|
-
jumpCount++;
|
|
334
333
|
}
|
|
335
334
|
}
|
|
336
335
|
};
|
|
@@ -380,7 +379,6 @@ const createVirtualStore = (elementsCount, itemSize = 40, overscan = 4, ssrCount
|
|
|
380
379
|
$getViewportSize: () => viewportSize,
|
|
381
380
|
$getStartSpacerSize: () => startSpacerSize,
|
|
382
381
|
$getTotalSize: getTotalSize,
|
|
383
|
-
$getJumpCount: () => jumpCount,
|
|
384
382
|
_flushJump: () => {
|
|
385
383
|
_flushedJump = jump;
|
|
386
384
|
jump = 0;
|
|
@@ -549,11 +547,10 @@ const createVirtualStore = (elementsCount, itemSize = 40, overscan = 4, ssrCount
|
|
|
549
547
|
}
|
|
550
548
|
}
|
|
551
549
|
if (mutated) {
|
|
552
|
-
stateVersion =
|
|
550
|
+
stateVersion = (stateVersion & MAX_INT_32) + 1;
|
|
553
551
|
if (shouldFlushPendingJump && pendingJump) {
|
|
554
552
|
jump += pendingJump;
|
|
555
553
|
pendingJump = 0;
|
|
556
|
-
jumpCount++;
|
|
557
554
|
}
|
|
558
555
|
subscribers.forEach(([target, cb]) => {
|
|
559
556
|
// Early return to skip React's computation
|
|
@@ -1354,7 +1351,7 @@ const Virtualizer = (props) => {
|
|
|
1354
1351
|
const store = createVirtualStore(props.data.length, itemSize, overscan, undefined, undefined, !itemSize);
|
|
1355
1352
|
const resizer = createResizer(store, horizontal);
|
|
1356
1353
|
const scroller = createScroller(store, horizontal);
|
|
1357
|
-
const [
|
|
1354
|
+
const [stateVersion, setRerender] = createSignal(store.$getStateVersion());
|
|
1358
1355
|
const unsubscribeStore = store.$subscribe(UPDATE_VIRTUAL_STATE, () => {
|
|
1359
1356
|
setRerender(store.$getStateVersion());
|
|
1360
1357
|
});
|
|
@@ -1367,16 +1364,15 @@ const Virtualizer = (props) => {
|
|
|
1367
1364
|
(_a = props.onScrollEnd) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
1368
1365
|
});
|
|
1369
1366
|
const range = createMemo((prev) => {
|
|
1370
|
-
|
|
1367
|
+
stateVersion();
|
|
1371
1368
|
const next = store.$getRange();
|
|
1372
1369
|
if (prev && isSameRange(prev, next)) {
|
|
1373
1370
|
return prev;
|
|
1374
1371
|
}
|
|
1375
1372
|
return next;
|
|
1376
1373
|
});
|
|
1377
|
-
const isScrolling = createMemo(() =>
|
|
1378
|
-
const totalSize = createMemo(() =>
|
|
1379
|
-
const jumpCount = createMemo(() => rerender() && store.$getJumpCount());
|
|
1374
|
+
const isScrolling = createMemo(() => stateVersion() && store.$isScrolling());
|
|
1375
|
+
const totalSize = createMemo(() => stateVersion() && store.$getTotalSize());
|
|
1380
1376
|
onMount(() => {
|
|
1381
1377
|
if (props.ref) {
|
|
1382
1378
|
props.ref({
|
|
@@ -1422,7 +1418,7 @@ const Virtualizer = (props) => {
|
|
|
1422
1418
|
store.$update(ACTION_START_OFFSET_CHANGE, value);
|
|
1423
1419
|
}
|
|
1424
1420
|
}));
|
|
1425
|
-
createEffect(on(
|
|
1421
|
+
createEffect(on(stateVersion, () => {
|
|
1426
1422
|
scroller.$fixScrollJump();
|
|
1427
1423
|
}));
|
|
1428
1424
|
return (<Dynamic component={props.as} ref={containerRef} style={{
|
|
@@ -1437,11 +1433,11 @@ const Virtualizer = (props) => {
|
|
|
1437
1433
|
}}>
|
|
1438
1434
|
<RangedFor _each={props.data} _range={range()} _render={(data, index) => {
|
|
1439
1435
|
const offset = createMemo(() => {
|
|
1440
|
-
|
|
1436
|
+
stateVersion();
|
|
1441
1437
|
return store.$getItemOffset(index);
|
|
1442
1438
|
});
|
|
1443
1439
|
const hide = createMemo(() => {
|
|
1444
|
-
|
|
1440
|
+
stateVersion();
|
|
1445
1441
|
return store.$isUnmeasuredItem(index);
|
|
1446
1442
|
});
|
|
1447
1443
|
return (<ListItem _as={props.item} _index={index} _resizer={resizer.$observeItem} _offset={offset()} _hide={hide()} _children={props.children(data(), index)} _isHorizontal={horizontal}/>);
|
|
@@ -1480,7 +1476,7 @@ const WindowVirtualizer = (props) => {
|
|
|
1480
1476
|
const store = createVirtualStore(props.data.length, itemSize, overscan, undefined, undefined, !itemSize);
|
|
1481
1477
|
const resizer = createWindowResizer(store, horizontal);
|
|
1482
1478
|
const scroller = createWindowScroller(store, horizontal);
|
|
1483
|
-
const [
|
|
1479
|
+
const [stateVersion, setRerender] = createSignal(store.$getStateVersion());
|
|
1484
1480
|
const unsubscribeStore = store.$subscribe(UPDATE_VIRTUAL_STATE, () => {
|
|
1485
1481
|
setRerender(store.$getStateVersion());
|
|
1486
1482
|
});
|
|
@@ -1494,16 +1490,15 @@ const WindowVirtualizer = (props) => {
|
|
|
1494
1490
|
(_a = props.onScrollEnd) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
1495
1491
|
});
|
|
1496
1492
|
const range = createMemo((prev) => {
|
|
1497
|
-
|
|
1493
|
+
stateVersion();
|
|
1498
1494
|
const next = store.$getRange();
|
|
1499
1495
|
if (prev && isSameRange(prev, next)) {
|
|
1500
1496
|
return prev;
|
|
1501
1497
|
}
|
|
1502
1498
|
return next;
|
|
1503
1499
|
});
|
|
1504
|
-
const isScrolling = createMemo(() =>
|
|
1505
|
-
const totalSize = createMemo(() =>
|
|
1506
|
-
const jumpCount = createMemo(() => rerender() && store.$getJumpCount());
|
|
1500
|
+
const isScrolling = createMemo(() => stateVersion() && store.$isScrolling());
|
|
1501
|
+
const totalSize = createMemo(() => stateVersion() && store.$getTotalSize());
|
|
1507
1502
|
onMount(() => {
|
|
1508
1503
|
if (props.ref) {
|
|
1509
1504
|
props.ref({
|
|
@@ -1530,7 +1525,7 @@ const WindowVirtualizer = (props) => {
|
|
|
1530
1525
|
store.$update(ACTION_ITEMS_LENGTH_CHANGE, [len, props.shift]);
|
|
1531
1526
|
}
|
|
1532
1527
|
}));
|
|
1533
|
-
createEffect(on(
|
|
1528
|
+
createEffect(on(stateVersion, () => {
|
|
1534
1529
|
scroller.$fixScrollJump();
|
|
1535
1530
|
}));
|
|
1536
1531
|
return (<div ref={containerRef} style={{
|
|
@@ -1545,11 +1540,11 @@ const WindowVirtualizer = (props) => {
|
|
|
1545
1540
|
}}>
|
|
1546
1541
|
<RangedFor _each={props.data} _range={range()} _render={(data, index) => {
|
|
1547
1542
|
const offset = createMemo(() => {
|
|
1548
|
-
|
|
1543
|
+
stateVersion();
|
|
1549
1544
|
return store.$getItemOffset(index);
|
|
1550
1545
|
});
|
|
1551
1546
|
const hide = createMemo(() => {
|
|
1552
|
-
|
|
1547
|
+
stateVersion();
|
|
1553
1548
|
return store.$isUnmeasuredItem(index);
|
|
1554
1549
|
});
|
|
1555
1550
|
return (<ListItem _index={index} _resizer={resizer.$observeItem} _offset={offset()} _hide={hide()} _children={props.children(data(), index)} _isHorizontal={horizontal}/>);
|