virtua 0.50.2 → 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 +2 -2
- package/lib/svelte/Virtualizer.svelte +18 -24
- package/lib/svelte/WindowVirtualizer.svelte +12 -13
- 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 +1 -1
- /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
|
});
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
let range = $derived(stateVersion && store.$getRange(bufferSize));
|
|
71
72
|
let isScrolling = $derived(stateVersion && store.$isScrolling());
|
|
72
73
|
let totalSize = $derived(stateVersion && store.$getTotalSize());
|
|
73
|
-
let negative = $derived(stateVersion &&
|
|
74
|
+
let negative = $derived(stateVersion && driver.$isNegative());
|
|
74
75
|
|
|
75
76
|
let indexes = $derived.by(() => {
|
|
76
77
|
// https://github.com/inokawa/virtua/pull/847
|
|
@@ -107,15 +108,7 @@
|
|
|
107
108
|
tick().then(() => {
|
|
108
109
|
// https://github.com/inokawa/virtua/pull/914
|
|
109
110
|
if (unmounted) return;
|
|
110
|
-
|
|
111
|
-
resizer.$observeRoot(scrollable);
|
|
112
|
-
scroller.$observe(container, scrollable);
|
|
113
|
-
};
|
|
114
|
-
if (scrollRef) {
|
|
115
|
-
assignRef(scrollRef);
|
|
116
|
-
} else {
|
|
117
|
-
assignRef(container.parentElement!);
|
|
118
|
-
}
|
|
111
|
+
driver.$observe(container, scrollRef);
|
|
119
112
|
});
|
|
120
113
|
return () => {
|
|
121
114
|
unmounted = true;
|
|
@@ -123,8 +116,7 @@
|
|
|
123
116
|
});
|
|
124
117
|
onDestroy(() => {
|
|
125
118
|
store.$dispose();
|
|
126
|
-
|
|
127
|
-
scroller.$dispose();
|
|
119
|
+
driver.$dispose();
|
|
128
120
|
});
|
|
129
121
|
|
|
130
122
|
$effect.pre(() => {
|
|
@@ -143,7 +135,7 @@
|
|
|
143
135
|
$effect(() => {
|
|
144
136
|
if (prevStateVersion === stateVersion) return;
|
|
145
137
|
prevStateVersion = stateVersion;
|
|
146
|
-
|
|
138
|
+
driver.$fixScrollJump();
|
|
147
139
|
});
|
|
148
140
|
|
|
149
141
|
export const getCache =
|
|
@@ -162,12 +154,14 @@
|
|
|
162
154
|
store.$getItemOffset satisfies VirtualizerHandle["getItemOffset"] as VirtualizerHandle["getItemOffset"];
|
|
163
155
|
export const getItemSize =
|
|
164
156
|
store.$getItemSize satisfies VirtualizerHandle["getItemSize"] as VirtualizerHandle["getItemSize"];
|
|
165
|
-
export const scrollToIndex =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
export const
|
|
170
|
-
|
|
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);
|
|
171
165
|
|
|
172
166
|
let containerStyle = $derived(
|
|
173
167
|
styleToString({
|
|
@@ -198,7 +192,7 @@
|
|
|
198
192
|
hide={stateVersion && store.$isUnmeasuredItem(index)}
|
|
199
193
|
{horizontal}
|
|
200
194
|
{isSSR}
|
|
201
|
-
resizer={
|
|
195
|
+
resizer={driver.$observeItem}
|
|
202
196
|
itemProps={itemProps?.({ item, index })}
|
|
203
197
|
/>
|
|
204
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>
|