virtua 0.38.2 → 0.38.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 +4 -4
- package/lib/core/index.js +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/solid/index.js +1 -1
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.jsx +25 -48
- 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/VList.svelte +1 -1
- package/lib/svelte/WindowVirtualizer.svelte +1 -1
- 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 +1 -1
package/lib/solid/index.jsx
CHANGED
|
@@ -5,10 +5,6 @@ import { Dynamic } from 'solid-js/web';
|
|
|
5
5
|
const NULL = null;
|
|
6
6
|
/** @internal */
|
|
7
7
|
const { min, max, abs, floor } = Math;
|
|
8
|
-
/** @internal */
|
|
9
|
-
const values = Object.values;
|
|
10
|
-
/** @internal */
|
|
11
|
-
const timeout = setTimeout;
|
|
12
8
|
/**
|
|
13
9
|
* @internal
|
|
14
10
|
*/
|
|
@@ -27,26 +23,6 @@ const microtask = typeof queueMicrotask === "function"
|
|
|
27
23
|
: (fn) => {
|
|
28
24
|
Promise.resolve().then(fn);
|
|
29
25
|
};
|
|
30
|
-
/**
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
const debounce = (fn, ms) => {
|
|
34
|
-
let id;
|
|
35
|
-
const cancel = () => {
|
|
36
|
-
if (id != NULL) {
|
|
37
|
-
clearTimeout(id);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const debouncedFn = () => {
|
|
41
|
-
cancel();
|
|
42
|
-
id = timeout(() => {
|
|
43
|
-
id = NULL;
|
|
44
|
-
fn();
|
|
45
|
-
}, ms);
|
|
46
|
-
};
|
|
47
|
-
debouncedFn._cancel = cancel;
|
|
48
|
-
return debouncedFn;
|
|
49
|
-
};
|
|
50
26
|
/**
|
|
51
27
|
* @internal
|
|
52
28
|
*/
|
|
@@ -61,17 +37,6 @@ const once = (fn) => {
|
|
|
61
37
|
return cache;
|
|
62
38
|
};
|
|
63
39
|
};
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
const getStyleNumber = (v) => {
|
|
68
|
-
if (v) {
|
|
69
|
-
return parseFloat(v);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return 0;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
40
|
|
|
76
41
|
/** @internal */
|
|
77
42
|
const UNCACHED = -1;
|
|
@@ -598,6 +563,24 @@ const createVirtualStore = (elementsCount, itemSize = 40, overscan = 4, ssrCount
|
|
|
598
563
|
};
|
|
599
564
|
};
|
|
600
565
|
|
|
566
|
+
const timeout = setTimeout;
|
|
567
|
+
const debounce = (fn, ms) => {
|
|
568
|
+
let id;
|
|
569
|
+
const cancel = () => {
|
|
570
|
+
if (id != NULL) {
|
|
571
|
+
clearTimeout(id);
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
const debouncedFn = () => {
|
|
575
|
+
cancel();
|
|
576
|
+
id = timeout(() => {
|
|
577
|
+
id = NULL;
|
|
578
|
+
fn();
|
|
579
|
+
}, ms);
|
|
580
|
+
};
|
|
581
|
+
debouncedFn._cancel = cancel;
|
|
582
|
+
return debouncedFn;
|
|
583
|
+
};
|
|
601
584
|
/**
|
|
602
585
|
* scrollLeft is negative value in rtl direction.
|
|
603
586
|
*
|
|
@@ -984,27 +967,21 @@ const createWindowScroller = (store, isHorizontal) => {
|
|
|
984
967
|
}
|
|
985
968
|
const document = getCurrentDocument(containerElement);
|
|
986
969
|
const window = getCurrentWindow(document);
|
|
970
|
+
const html = document.documentElement;
|
|
971
|
+
const getScrollbarSize = () => store.$getViewportSize() -
|
|
972
|
+
(isHorizontal ? html.clientWidth : html.clientHeight);
|
|
987
973
|
scheduleImperativeScroll(() => {
|
|
988
|
-
// Calculate target scroll position including container's offset from document
|
|
989
|
-
const containerOffset = calcOffsetToViewport(containerElement, document.body, window, isHorizontal);
|
|
990
|
-
// slight tech debt: this would otherwise need to be accounted for in store._getViewportSize in a way that's flexible for windowScroller
|
|
991
|
-
const scrollbarHeight = window.innerHeight - document.documentElement.clientHeight;
|
|
992
|
-
const scrollbarWidth = window.innerHeight - document.documentElement.clientWidth;
|
|
993
|
-
const viewportAdjustment = align === "end" || align === "center"
|
|
994
|
-
? isHorizontal
|
|
995
|
-
? scrollbarWidth
|
|
996
|
-
: scrollbarHeight
|
|
997
|
-
: 0;
|
|
998
974
|
return (offset +
|
|
999
|
-
|
|
975
|
+
// Calculate target scroll position including container's offset from document
|
|
976
|
+
calcOffsetToViewport(containerElement, document.body, window, isHorizontal) +
|
|
1000
977
|
// store._getStartSpacerSize() +
|
|
1001
978
|
store.$getItemOffset(index) +
|
|
1002
979
|
(align === "end"
|
|
1003
980
|
? store.$getItemSize(index) -
|
|
1004
|
-
(store.$getViewportSize() -
|
|
981
|
+
(store.$getViewportSize() - getScrollbarSize())
|
|
1005
982
|
: align === "center"
|
|
1006
983
|
? (store.$getItemSize(index) -
|
|
1007
|
-
(store.$getViewportSize() -
|
|
984
|
+
(store.$getViewportSize() - getScrollbarSize())) /
|
|
1008
985
|
2
|
|
1009
986
|
: 0));
|
|
1010
987
|
}, smooth);
|