virtua 0.48.1 → 0.48.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/README.md +2 -26
- package/lib/core/index.cjs +1 -1
- package/lib/core/index.cjs.map +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/solid/index.cjs +1 -1
- package/lib/solid/index.cjs.map +1 -1
- package/lib/solid/index.js +1 -1
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.jsx +15 -31
- package/lib/solid/index.jsx.map +1 -1
- package/lib/svelte/Virtualizer.svelte +5 -5
- package/lib/svelte/WindowVirtualizer.svelte +1 -2
- package/lib/vue/index.cjs +1 -1
- package/lib/vue/index.cjs.map +1 -1
- package/lib/vue/index.js +1 -1
- package/lib/vue/index.js.map +1 -1
- package/package.json +18 -18
package/lib/solid/index.jsx
CHANGED
|
@@ -807,26 +807,11 @@ const createScroller = (store, isHorizontal) => {
|
|
|
807
807
|
}
|
|
808
808
|
});
|
|
809
809
|
return {
|
|
810
|
-
$observe(viewport) {
|
|
810
|
+
$observe(_, viewport) {
|
|
811
811
|
viewportElement = viewport;
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
const prev = viewport[scrollOffsetKey];
|
|
816
|
-
// Detect overflowed direction after the initial viewport measurement
|
|
817
|
-
const dummy = getCurrentDocument(viewport).createElement("div");
|
|
818
|
-
dummy.style.cssText = `visibility:hidden;min-${isHorizontal ? "width" : "height"}:${
|
|
819
|
-
// Set larger value than the viewportSize to force overflow. And the value must take subpixels into account.
|
|
820
|
-
viewportSize + 9}px`;
|
|
821
|
-
viewport.appendChild(dummy);
|
|
822
|
-
viewport[scrollOffsetKey] = 1;
|
|
823
|
-
// It can be positive under some specific situations even if negative mode, so we use `<` for now.
|
|
824
|
-
isNegative = viewport[scrollOffsetKey] < 1;
|
|
825
|
-
viewport.removeChild(dummy);
|
|
826
|
-
viewport[scrollOffsetKey] = prev;
|
|
827
|
-
clean();
|
|
828
|
-
}
|
|
829
|
-
});
|
|
812
|
+
if (isHorizontal) {
|
|
813
|
+
isNegative = getComputedStyle(viewport).direction === "rtl";
|
|
814
|
+
}
|
|
830
815
|
scrollObserver = createScrollObserver(store, viewport, isHorizontal, () => normalizeScrollOffset(viewport[scrollOffsetKey], isNegative), (jump, shift, isMomentumScrolling) => {
|
|
831
816
|
// If we update scroll position while touching on iOS, the position will be reverted.
|
|
832
817
|
// However iOS WebKit fires touch events only once at the beginning of momentum scrolling.
|
|
@@ -1021,9 +1006,9 @@ const createGridScroller = (rowStore, colStore) => {
|
|
|
1021
1006
|
const rowScroller = createScroller(rowStore, false);
|
|
1022
1007
|
const colScroller = createScroller(colStore, true);
|
|
1023
1008
|
return {
|
|
1024
|
-
$observe(
|
|
1025
|
-
rowScroller.$observe(
|
|
1026
|
-
colScroller.$observe(
|
|
1009
|
+
$observe(container, viewport) {
|
|
1010
|
+
rowScroller.$observe(container, viewport);
|
|
1011
|
+
colScroller.$observe(container, viewport);
|
|
1027
1012
|
},
|
|
1028
1013
|
$dispose() {
|
|
1029
1014
|
rowScroller.$dispose();
|
|
@@ -1388,9 +1373,10 @@ const Virtualizer = (props) => {
|
|
|
1388
1373
|
scrollBy: scroller.$scrollBy,
|
|
1389
1374
|
});
|
|
1390
1375
|
}
|
|
1391
|
-
const
|
|
1376
|
+
const container = containerRef;
|
|
1377
|
+
const scrollable = props.scrollRef || container.parentElement;
|
|
1392
1378
|
resizer.$observeRoot(scrollable);
|
|
1393
|
-
scroller.$observe(scrollable);
|
|
1379
|
+
scroller.$observe(container, scrollable);
|
|
1394
1380
|
onCleanup(() => {
|
|
1395
1381
|
if (props.ref) {
|
|
1396
1382
|
props.ref();
|
|
@@ -1415,7 +1401,6 @@ const Virtualizer = (props) => {
|
|
|
1415
1401
|
store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);
|
|
1416
1402
|
}
|
|
1417
1403
|
});
|
|
1418
|
-
const pushKey = !horizontal && isNegative() ? "unshift" : "push";
|
|
1419
1404
|
const items = [];
|
|
1420
1405
|
const indexes = [];
|
|
1421
1406
|
if (props.keepMounted) {
|
|
@@ -1424,14 +1409,14 @@ const Virtualizer = (props) => {
|
|
|
1424
1409
|
mounted.add(i);
|
|
1425
1410
|
}
|
|
1426
1411
|
sort([...mounted]).forEach((index) => {
|
|
1427
|
-
items
|
|
1428
|
-
indexes
|
|
1412
|
+
items.push(props.data[index]);
|
|
1413
|
+
indexes.push(index);
|
|
1429
1414
|
});
|
|
1430
1415
|
}
|
|
1431
1416
|
else {
|
|
1432
1417
|
for (let [i, j] = range(); i <= j; i++) {
|
|
1433
|
-
items
|
|
1434
|
-
indexes
|
|
1418
|
+
items.push(props.data[i]);
|
|
1419
|
+
indexes.push(i);
|
|
1435
1420
|
}
|
|
1436
1421
|
}
|
|
1437
1422
|
return { _items: items, _indexes: indexes };
|
|
@@ -1580,10 +1565,9 @@ const WindowVirtualizer = (props) => {
|
|
|
1580
1565
|
store.$update(ACTION_ITEMS_LENGTH_CHANGE, [count, props.shift]);
|
|
1581
1566
|
}
|
|
1582
1567
|
});
|
|
1583
|
-
const pushKey = !horizontal && isNegative() ? "unshift" : "push";
|
|
1584
1568
|
const items = [];
|
|
1585
1569
|
for (let [i, j] = range(); i <= j; i++) {
|
|
1586
|
-
items
|
|
1570
|
+
items.push(props.data[i]);
|
|
1587
1571
|
}
|
|
1588
1572
|
return items;
|
|
1589
1573
|
});
|