virtua 0.50.1 → 0.50.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/angular/VList.d.ts +7 -7
- package/lib/angular/Virtualizer.d.ts +11 -11
- package/lib/angular/WindowVirtualizer.d.ts +9 -9
- package/lib/angular/index.js +306 -328
- package/lib/angular/index.js.map +1 -1
- package/lib/core/index.cjs +283 -280
- package/lib/core/index.cjs.map +1 -1
- package/lib/core/index.d.ts +3 -2
- package/lib/core/index.js +317 -313
- package/lib/core/index.js.map +1 -1
- package/lib/core/scroll-to.d.ts +1 -0
- package/lib/core/types.d.ts +1 -5
- package/lib/index.cjs +514 -516
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +437 -439
- package/lib/index.js.map +1 -1
- package/lib/solid/index.cjs +296 -322
- package/lib/solid/index.cjs.map +1 -1
- package/lib/solid/index.js +261 -287
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.jsx +230 -223
- package/lib/solid/index.jsx.map +1 -1
- package/lib/svelte/ListItem.svelte +6 -4
- package/lib/svelte/Virtualizer.svelte +23 -24
- package/lib/svelte/WindowVirtualizer.svelte +12 -13
- package/lib/svelte/index.d.ts +1 -1
- package/lib/vue/index.cjs +305 -332
- package/lib/vue/index.cjs.map +1 -1
- package/lib/vue/index.js +272 -299
- package/lib/vue/index.js.map +1 -1
- package/package.json +2 -4
- /package/lib/core/{resizer.d.ts → driver.d.ts} +0 -0
- /package/lib/core/{scroller.d.ts → observer.d.ts} +0 -0
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
UPDATE_SCROLL_END_EVENT,
|
|
8
8
|
UPDATE_SCROLL_EVENT,
|
|
9
9
|
UPDATE_VIRTUAL_STATE,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
createContainerDriver,
|
|
11
|
+
scrollTo as _scrollTo,
|
|
12
|
+
scrollBy as _scrollBy,
|
|
13
|
+
scrollToIndex as _scrollToIndex,
|
|
12
14
|
createVirtualStore,
|
|
13
15
|
getScrollSize as _getScrollSize,
|
|
14
16
|
sort,
|
|
@@ -49,8 +51,7 @@
|
|
|
49
51
|
cache,
|
|
50
52
|
!itemSize,
|
|
51
53
|
);
|
|
52
|
-
const
|
|
53
|
-
const scroller = createScroller(store, horizontal);
|
|
54
|
+
const driver = createContainerDriver(store, horizontal);
|
|
54
55
|
store.$subscribe(UPDATE_VIRTUAL_STATE, () => {
|
|
55
56
|
stateVersion = store.$getStateVersion();
|
|
56
57
|
});
|
|
@@ -61,6 +62,8 @@
|
|
|
61
62
|
onscrollend && onscrollend();
|
|
62
63
|
});
|
|
63
64
|
|
|
65
|
+
let isSSR = $state(!!ssrCount);
|
|
66
|
+
|
|
64
67
|
let containerRef: HTMLDivElement | undefined = $state();
|
|
65
68
|
|
|
66
69
|
let stateVersion: StateVersion = $state(store.$getStateVersion());
|
|
@@ -68,7 +71,7 @@
|
|
|
68
71
|
let range = $derived(stateVersion && store.$getRange(bufferSize));
|
|
69
72
|
let isScrolling = $derived(stateVersion && store.$isScrolling());
|
|
70
73
|
let totalSize = $derived(stateVersion && store.$getTotalSize());
|
|
71
|
-
let negative = $derived(stateVersion &&
|
|
74
|
+
let negative = $derived(stateVersion && driver.$isNegative());
|
|
72
75
|
|
|
73
76
|
let indexes = $derived.by(() => {
|
|
74
77
|
// https://github.com/inokawa/virtua/pull/847
|
|
@@ -97,21 +100,15 @@
|
|
|
97
100
|
});
|
|
98
101
|
|
|
99
102
|
onMount(() => {
|
|
103
|
+
isSSR = false;
|
|
104
|
+
|
|
100
105
|
let unmounted = false;
|
|
101
106
|
const container = containerRef!;
|
|
102
107
|
// parent's ref may not exist on mount https://github.com/inokawa/virtua/issues/603 https://github.com/inokawa/virtua/issues/690
|
|
103
108
|
tick().then(() => {
|
|
104
109
|
// https://github.com/inokawa/virtua/pull/914
|
|
105
110
|
if (unmounted) return;
|
|
106
|
-
|
|
107
|
-
resizer.$observeRoot(scrollable);
|
|
108
|
-
scroller.$observe(container, scrollable);
|
|
109
|
-
};
|
|
110
|
-
if (scrollRef) {
|
|
111
|
-
assignRef(scrollRef);
|
|
112
|
-
} else {
|
|
113
|
-
assignRef(container.parentElement!);
|
|
114
|
-
}
|
|
111
|
+
driver.$observe(container, scrollRef);
|
|
115
112
|
});
|
|
116
113
|
return () => {
|
|
117
114
|
unmounted = true;
|
|
@@ -119,8 +116,7 @@
|
|
|
119
116
|
});
|
|
120
117
|
onDestroy(() => {
|
|
121
118
|
store.$dispose();
|
|
122
|
-
|
|
123
|
-
scroller.$dispose();
|
|
119
|
+
driver.$dispose();
|
|
124
120
|
});
|
|
125
121
|
|
|
126
122
|
$effect.pre(() => {
|
|
@@ -139,7 +135,7 @@
|
|
|
139
135
|
$effect(() => {
|
|
140
136
|
if (prevStateVersion === stateVersion) return;
|
|
141
137
|
prevStateVersion = stateVersion;
|
|
142
|
-
|
|
138
|
+
driver.$fixScrollJump();
|
|
143
139
|
});
|
|
144
140
|
|
|
145
141
|
export const getCache =
|
|
@@ -158,12 +154,14 @@
|
|
|
158
154
|
store.$getItemOffset satisfies VirtualizerHandle["getItemOffset"] as VirtualizerHandle["getItemOffset"];
|
|
159
155
|
export const getItemSize =
|
|
160
156
|
store.$getItemSize satisfies VirtualizerHandle["getItemSize"] as VirtualizerHandle["getItemSize"];
|
|
161
|
-
export const scrollToIndex =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
export const
|
|
166
|
-
|
|
157
|
+
export const scrollToIndex: VirtualizerHandle["scrollToIndex"] = (
|
|
158
|
+
index,
|
|
159
|
+
opts,
|
|
160
|
+
) => _scrollToIndex(driver, store, index, opts);
|
|
161
|
+
export const scrollTo: VirtualizerHandle["scrollTo"] = (offset) =>
|
|
162
|
+
_scrollTo(driver, offset);
|
|
163
|
+
export const scrollBy: VirtualizerHandle["scrollBy"] = (offset) =>
|
|
164
|
+
_scrollBy(driver, store, offset);
|
|
167
165
|
|
|
168
166
|
let containerStyle = $derived(
|
|
169
167
|
styleToString({
|
|
@@ -193,7 +191,8 @@
|
|
|
193
191
|
offset={stateVersion && store.$getItemOffset(index, negative)}
|
|
194
192
|
hide={stateVersion && store.$isUnmeasuredItem(index)}
|
|
195
193
|
{horizontal}
|
|
196
|
-
|
|
194
|
+
{isSSR}
|
|
195
|
+
resizer={driver.$observeItem}
|
|
197
196
|
itemProps={itemProps?.({ item, index })}
|
|
198
197
|
/>
|
|
199
198
|
{/each}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
UPDATE_VIRTUAL_STATE,
|
|
9
9
|
createVirtualStore,
|
|
10
10
|
getScrollSize as _getScrollSize,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
createWindowDriver,
|
|
12
|
+
scrollToIndex as _scrollToIndex,
|
|
13
13
|
} from "../core/index.js";
|
|
14
14
|
import { defaultGetKey, styleToString } from "./utils.js";
|
|
15
15
|
import ListItem from "./ListItem.svelte";
|
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
cache,
|
|
41
41
|
!itemSize,
|
|
42
42
|
);
|
|
43
|
-
const
|
|
44
|
-
const scroller = createWindowScroller(store, horizontal);
|
|
43
|
+
const driver = createWindowDriver(store, horizontal);
|
|
45
44
|
store.$subscribe(UPDATE_VIRTUAL_STATE, () => {
|
|
46
45
|
stateVersion = store.$getStateVersion();
|
|
47
46
|
});
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
let range = $derived(stateVersion && store.$getRange(bufferSize));
|
|
61
60
|
let isScrolling = $derived(stateVersion && store.$isScrolling());
|
|
62
61
|
let totalSize = $derived(stateVersion && store.$getTotalSize());
|
|
63
|
-
let negative = $derived(stateVersion &&
|
|
62
|
+
let negative = $derived(stateVersion && driver.$isNegative());
|
|
64
63
|
|
|
65
64
|
let indexes = $derived.by(() => {
|
|
66
65
|
// https://github.com/inokawa/virtua/pull/847
|
|
@@ -77,13 +76,11 @@
|
|
|
77
76
|
});
|
|
78
77
|
|
|
79
78
|
onMount(() => {
|
|
80
|
-
|
|
81
|
-
scroller.$observe(containerRef!);
|
|
79
|
+
driver.$observe(containerRef!);
|
|
82
80
|
});
|
|
83
81
|
onDestroy(() => {
|
|
84
82
|
store.$dispose();
|
|
85
|
-
|
|
86
|
-
scroller.$dispose();
|
|
83
|
+
driver.$dispose();
|
|
87
84
|
});
|
|
88
85
|
|
|
89
86
|
$effect.pre(() => {
|
|
@@ -96,7 +93,7 @@
|
|
|
96
93
|
$effect(() => {
|
|
97
94
|
if (prevStateVersion === stateVersion) return;
|
|
98
95
|
prevStateVersion = stateVersion;
|
|
99
|
-
|
|
96
|
+
driver.$fixScrollJump();
|
|
100
97
|
});
|
|
101
98
|
|
|
102
99
|
export const getCache =
|
|
@@ -111,8 +108,10 @@
|
|
|
111
108
|
store.$getItemOffset satisfies WindowVirtualizerHandle["getItemOffset"] as WindowVirtualizerHandle["getItemOffset"];
|
|
112
109
|
export const getItemSize =
|
|
113
110
|
store.$getItemSize satisfies WindowVirtualizerHandle["getItemSize"] as WindowVirtualizerHandle["getItemSize"];
|
|
114
|
-
export const scrollToIndex =
|
|
115
|
-
|
|
111
|
+
export const scrollToIndex: WindowVirtualizerHandle["scrollToIndex"] = (
|
|
112
|
+
index,
|
|
113
|
+
opts,
|
|
114
|
+
) => _scrollToIndex(driver, store, index, opts);
|
|
116
115
|
|
|
117
116
|
let containerStyle = $derived(
|
|
118
117
|
styleToString({
|
|
@@ -142,7 +141,7 @@
|
|
|
142
141
|
offset={stateVersion && store.$getItemOffset(index, negative)}
|
|
143
142
|
hide={stateVersion && store.$isUnmeasuredItem(index)}
|
|
144
143
|
{horizontal}
|
|
145
|
-
resizer={
|
|
144
|
+
resizer={driver.$observeItem}
|
|
146
145
|
/>
|
|
147
146
|
{/each}
|
|
148
147
|
</div>
|
package/lib/svelte/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export type { VListProps, VListHandle } from './VList.type.js';
|
|
|
6
6
|
export { default as Virtualizer } from './Virtualizer.svelte';
|
|
7
7
|
export type { VirtualizerProps, VirtualizerHandle, } from './Virtualizer.type.js';
|
|
8
8
|
export { default as WindowVirtualizer } from './WindowVirtualizer.svelte';
|
|
9
|
-
export type { WindowVirtualizerProps } from './WindowVirtualizer.type.js';
|
|
9
|
+
export type { WindowVirtualizerProps, WindowVirtualizerHandle, } from './WindowVirtualizer.type.js';
|