virtua 0.50.4 → 0.50.6
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/angular/index.js +163 -183
- package/lib/angular/index.js.map +1 -1
- package/lib/core/index.cjs +160 -181
- package/lib/core/index.cjs.map +1 -1
- package/lib/core/index.js +264 -285
- package/lib/core/index.js.map +1 -1
- package/lib/index.cjs +320 -341
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +293 -314
- package/lib/index.js.map +1 -1
- package/lib/solid/index.cjs +226 -246
- package/lib/solid/index.cjs.map +1 -1
- package/lib/solid/index.js +264 -284
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.jsx +77 -88
- package/lib/solid/index.jsx.map +1 -1
- package/lib/svelte/Virtualizer.svelte +1 -1
- package/lib/svelte/WindowVirtualizer.svelte +1 -1
- package/lib/vue/index.cjs +251 -271
- package/lib/vue/index.cjs.map +1 -1
- package/lib/vue/index.js +190 -210
- package/lib/vue/index.js.map +1 -1
- package/package.json +1 -1
package/lib/solid/index.jsx
CHANGED
|
@@ -9,6 +9,7 @@ var sort = (arr) => {
|
|
|
9
9
|
return [...arr].sort((a, b) => a - b);
|
|
10
10
|
};
|
|
11
11
|
var timeout = setTimeout;
|
|
12
|
+
var cancelTimeout = clearTimeout;
|
|
12
13
|
var microtask = typeof queueMicrotask === "function" ? queueMicrotask : (fn) => {
|
|
13
14
|
Promise.resolve().then(fn);
|
|
14
15
|
};
|
|
@@ -389,7 +390,9 @@ var createListLayout = (length, itemSize, snapshot) => {
|
|
|
389
390
|
const measuredSizes = [];
|
|
390
391
|
sizes.forEach((s, i) => {
|
|
391
392
|
if (s !== -1) {
|
|
392
|
-
|
|
393
|
+
if (s) {
|
|
394
|
+
measuredSizes.push(s);
|
|
395
|
+
}
|
|
393
396
|
if (i < startIndex) {
|
|
394
397
|
measuredCountBeforeStart++;
|
|
395
398
|
}
|
|
@@ -423,42 +426,30 @@ var createResizeObserver = (cb) => {
|
|
|
423
426
|
}
|
|
424
427
|
};
|
|
425
428
|
};
|
|
426
|
-
var debounce = (fn, ms) => {
|
|
427
|
-
let id;
|
|
428
|
-
const cancel = () => {
|
|
429
|
-
if (id != null) {
|
|
430
|
-
clearTimeout(id);
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
const debouncedFn = () => {
|
|
434
|
-
cancel();
|
|
435
|
-
id = timeout(() => {
|
|
436
|
-
id = null;
|
|
437
|
-
fn();
|
|
438
|
-
}, ms);
|
|
439
|
-
};
|
|
440
|
-
debouncedFn._cancel = cancel;
|
|
441
|
-
return debouncedFn;
|
|
442
|
-
};
|
|
443
429
|
var normalizeScrollOffset = (offset, isNegative) => {
|
|
444
430
|
return isNegative ? -offset : offset;
|
|
445
431
|
};
|
|
446
432
|
var createScrollObserver = (store, viewport, isHorizontal, getScrollOffset, updateScrollOffset, getStartOffset) => {
|
|
447
|
-
const now = Date.now;
|
|
448
433
|
let lastScrollTime = 0;
|
|
449
434
|
let wheeling = false;
|
|
450
435
|
let touching = false;
|
|
451
436
|
let justTouchEnded = false;
|
|
452
437
|
let stillMomentumScrolling = false;
|
|
453
|
-
|
|
438
|
+
let scrollEndTimer;
|
|
439
|
+
const now = Date.now;
|
|
440
|
+
const onScrollEnd = () => {
|
|
454
441
|
if (wheeling || touching) {
|
|
455
442
|
wheeling = false;
|
|
456
|
-
|
|
443
|
+
scheduleScrollEnd();
|
|
457
444
|
return;
|
|
458
445
|
}
|
|
459
446
|
justTouchEnded = false;
|
|
460
447
|
store.$update(2);
|
|
461
|
-
}
|
|
448
|
+
};
|
|
449
|
+
const scheduleScrollEnd = () => {
|
|
450
|
+
cancelTimeout(scrollEndTimer);
|
|
451
|
+
scrollEndTimer = timeout(onScrollEnd, 150);
|
|
452
|
+
};
|
|
462
453
|
const onScroll = () => {
|
|
463
454
|
lastScrollTime = now();
|
|
464
455
|
if (justTouchEnded) {
|
|
@@ -468,7 +459,7 @@ var createScrollObserver = (store, viewport, isHorizontal, getScrollOffset, upda
|
|
|
468
459
|
store.$update(6, getStartOffset());
|
|
469
460
|
}
|
|
470
461
|
store.$update(1, getScrollOffset());
|
|
471
|
-
|
|
462
|
+
scheduleScrollEnd();
|
|
472
463
|
};
|
|
473
464
|
const onWheel = ((e) => {
|
|
474
465
|
if (wheeling || !store.$isScrolling() || e.ctrlKey) {
|
|
@@ -499,7 +490,7 @@ var createScrollObserver = (store, viewport, isHorizontal, getScrollOffset, upda
|
|
|
499
490
|
viewport.removeEventListener("wheel", onWheel);
|
|
500
491
|
viewport.removeEventListener("touchstart", onTouchStart);
|
|
501
492
|
viewport.removeEventListener("touchend", onTouchEnd);
|
|
502
|
-
|
|
493
|
+
cancelTimeout(scrollEndTimer);
|
|
503
494
|
},
|
|
504
495
|
_fixScrollJump: () => {
|
|
505
496
|
const [jump, shift] = store._flushJump();
|
|
@@ -524,57 +515,56 @@ var createScrollScheduler = (store, initialized, scroll) => {
|
|
|
524
515
|
if (cancelScroll) {
|
|
525
516
|
cancelScroll();
|
|
526
517
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
518
|
+
let stopped;
|
|
519
|
+
let timerId;
|
|
520
|
+
let unsubscribe;
|
|
521
|
+
const isSmooth = smooth && isSmoothScrollSupported();
|
|
522
|
+
const stop = cancelScroll = () => {
|
|
523
|
+
stopped = true;
|
|
524
|
+
cancelTimeout(timerId);
|
|
525
|
+
unsubscribe && unsubscribe();
|
|
526
|
+
};
|
|
527
|
+
const onMeasured = () => {
|
|
528
|
+
if (stopped) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
532
531
|
if (store.$getViewportSize()) {
|
|
533
|
-
|
|
532
|
+
cancelTimeout(timerId);
|
|
533
|
+
timerId = timeout(stop, 150);
|
|
534
534
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
};
|
|
539
|
-
if (smooth && isSmoothScrollSupported()) {
|
|
540
|
-
store.$update(8, getTargetOffset());
|
|
541
|
-
microtask(async () => {
|
|
542
|
-
while (true) {
|
|
543
|
-
let done = true;
|
|
544
|
-
for (let [i, end] = store.$getRange(); i <= end; i++) {
|
|
545
|
-
if (store.$isUnmeasuredItem(i)) {
|
|
546
|
-
done = false;
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
if (done) {
|
|
551
|
-
break;
|
|
552
|
-
}
|
|
553
|
-
const [promise, unsubscribe] = waitForMeasurement();
|
|
554
|
-
try {
|
|
555
|
-
if (!await promise) {
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
} finally {
|
|
559
|
-
unsubscribe();
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
store.$update(7);
|
|
563
|
-
scroll(getTargetOffset(), smooth);
|
|
564
|
-
});
|
|
565
|
-
} else {
|
|
566
|
-
while (true) {
|
|
567
|
-
const [promise, unsubscribe] = waitForMeasurement();
|
|
568
|
-
try {
|
|
569
|
-
store.$update(7);
|
|
570
|
-
scroll(getTargetOffset());
|
|
571
|
-
if (!await promise) {
|
|
535
|
+
if (isSmooth) {
|
|
536
|
+
for (let [i, end] = store.$getRange(0); i <= end; i++) {
|
|
537
|
+
if (store.$isUnmeasuredItem(i)) {
|
|
572
538
|
return;
|
|
573
539
|
}
|
|
574
|
-
} finally {
|
|
575
|
-
unsubscribe();
|
|
576
540
|
}
|
|
541
|
+
stop();
|
|
542
|
+
}
|
|
543
|
+
store.$update(7);
|
|
544
|
+
scroll(getTargetOffset(), isSmooth);
|
|
545
|
+
};
|
|
546
|
+
const start = () => {
|
|
547
|
+
if (stopped) {
|
|
548
|
+
return;
|
|
577
549
|
}
|
|
550
|
+
let queued;
|
|
551
|
+
unsubscribe = store.$subscribe(2, () => {
|
|
552
|
+
if (queued) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
queued = true;
|
|
556
|
+
microtask(() => {
|
|
557
|
+
queued = false;
|
|
558
|
+
onMeasured();
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
onMeasured();
|
|
562
|
+
};
|
|
563
|
+
if (isSmooth) {
|
|
564
|
+
store.$update(8, getTargetOffset());
|
|
565
|
+
microtask(start);
|
|
566
|
+
} else {
|
|
567
|
+
start();
|
|
578
568
|
}
|
|
579
569
|
}, () => {
|
|
580
570
|
cancelScroll && cancelScroll();
|
|
@@ -654,8 +644,8 @@ var createContainerDriver = (store, isHorizontal) => {
|
|
|
654
644
|
};
|
|
655
645
|
},
|
|
656
646
|
$isNegative: () => isNegative,
|
|
657
|
-
$
|
|
658
|
-
$
|
|
647
|
+
$scroll: scheduleScroll,
|
|
648
|
+
$effect() {
|
|
659
649
|
scrollObserver && scrollObserver._fixScrollJump();
|
|
660
650
|
},
|
|
661
651
|
$getBaseOffset: store.$getStartSpacerSize,
|
|
@@ -748,8 +738,8 @@ var createWindowDriver = (store, isHorizontal) => {
|
|
|
748
738
|
};
|
|
749
739
|
},
|
|
750
740
|
$isNegative: () => isNegative,
|
|
751
|
-
$
|
|
752
|
-
$
|
|
741
|
+
$scroll: scheduleScroll,
|
|
742
|
+
$effect() {
|
|
753
743
|
scrollObserver && scrollObserver._fixScrollJump();
|
|
754
744
|
},
|
|
755
745
|
$getBaseOffset() {
|
|
@@ -920,20 +910,19 @@ var createContainerGridDriver = (rowStore, colStore) => {
|
|
|
920
910
|
colStore.$update(3, cols);
|
|
921
911
|
},
|
|
922
912
|
$isNegative: () => isNegative,
|
|
923
|
-
$
|
|
924
|
-
$
|
|
925
|
-
$
|
|
913
|
+
$scrollX: scheduleScrollX,
|
|
914
|
+
$scrollY: scheduleScrollY,
|
|
915
|
+
$effect() {
|
|
926
916
|
rowScrollObserver && rowScrollObserver._fixScrollJump();
|
|
927
917
|
colScrollObserver && colScrollObserver._fixScrollJump();
|
|
928
|
-
}
|
|
929
|
-
$getBaseOffset: (isHorizontal) => (isHorizontal ? colStore : rowStore).$getStartSpacerSize()
|
|
918
|
+
}
|
|
930
919
|
};
|
|
931
920
|
};
|
|
932
921
|
|
|
933
922
|
//#endregion
|
|
934
923
|
//#region src/core/scroll-to.ts
|
|
935
924
|
var scrollTo = (driver, offset) => {
|
|
936
|
-
driver.$
|
|
925
|
+
driver.$scroll(() => offset);
|
|
937
926
|
};
|
|
938
927
|
var scrollBy = (driver, store, offset) => {
|
|
939
928
|
scrollTo(driver, offset + store.$getScrollOffset());
|
|
@@ -951,36 +940,36 @@ var scrollToIndex = (driver, store, index, { align, smooth, offset = 0 } = {}) =
|
|
|
951
940
|
return;
|
|
952
941
|
}
|
|
953
942
|
}
|
|
954
|
-
driver.$
|
|
943
|
+
driver.$scroll(() => {
|
|
955
944
|
return offset + driver.$getBaseOffset() + store.$getItemOffset(index) + (align === "end" ? store.$getItemSize(index) - (store.$getViewportSize() - driver.$getScrollbarSize()) : align === "center" ? (store.$getItemSize(index) - (store.$getViewportSize() - driver.$getScrollbarSize())) / 2 : 0);
|
|
956
945
|
}, smooth);
|
|
957
946
|
};
|
|
958
947
|
var gridScrollTo = (driver, row, col) => {
|
|
959
948
|
if (row != null) {
|
|
960
|
-
driver.$
|
|
949
|
+
driver.$scrollY(() => row);
|
|
961
950
|
}
|
|
962
951
|
if (col != null) {
|
|
963
|
-
driver.$
|
|
952
|
+
driver.$scrollX(() => col);
|
|
964
953
|
}
|
|
965
954
|
};
|
|
966
955
|
var gridScrollBy = (driver, rowStore, colStore, row, col) => {
|
|
967
956
|
if (row != null) {
|
|
968
957
|
const target = row + rowStore.$getScrollOffset();
|
|
969
|
-
driver.$
|
|
958
|
+
driver.$scrollY(() => target);
|
|
970
959
|
}
|
|
971
960
|
if (col != null) {
|
|
972
961
|
const target = col + colStore.$getScrollOffset();
|
|
973
|
-
driver.$
|
|
962
|
+
driver.$scrollX(() => target);
|
|
974
963
|
}
|
|
975
964
|
};
|
|
976
965
|
var gridScrollToIndex = (driver, rowStore, colStore, row, col) => {
|
|
977
966
|
if (row != null) {
|
|
978
967
|
const index = clamp(row, 0, rowStore.$getItemsLength() - 1);
|
|
979
|
-
driver.$
|
|
968
|
+
driver.$scrollY(() => rowStore.$getItemOffset(index));
|
|
980
969
|
}
|
|
981
970
|
if (col != null) {
|
|
982
971
|
const index = clamp(col, 0, colStore.$getItemsLength() - 1);
|
|
983
|
-
driver.$
|
|
972
|
+
driver.$scrollX(() => colStore.$getItemOffset(index));
|
|
984
973
|
}
|
|
985
974
|
};
|
|
986
975
|
|
|
@@ -1091,7 +1080,7 @@ var Virtualizer = (props) => {
|
|
|
1091
1080
|
}
|
|
1092
1081
|
}));
|
|
1093
1082
|
createEffect(on(stateVersion, () => {
|
|
1094
|
-
driver.$
|
|
1083
|
+
driver.$effect();
|
|
1095
1084
|
}));
|
|
1096
1085
|
const dataSlice = createMemo(() => {
|
|
1097
1086
|
const count = props.data.length;
|
|
@@ -1246,7 +1235,7 @@ var WindowVirtualizer = (props) => {
|
|
|
1246
1235
|
});
|
|
1247
1236
|
});
|
|
1248
1237
|
createEffect(on(stateVersion, () => {
|
|
1249
|
-
driver.$
|
|
1238
|
+
driver.$effect();
|
|
1250
1239
|
}));
|
|
1251
1240
|
const dataSlice = createMemo(() => {
|
|
1252
1241
|
const count = props.data.length;
|