virtua 0.50.6 → 0.51.1
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 +10 -5
- package/lib/angular/Virtualizer.d.ts +2 -2
- package/lib/angular/WindowVirtualizer.d.ts +2 -2
- package/lib/angular/index.js +245 -270
- package/lib/angular/index.js.map +1 -1
- package/lib/core/index.cjs +261 -298
- package/lib/core/index.cjs.map +1 -1
- package/lib/core/index.js +276 -313
- package/lib/core/index.js.map +1 -1
- package/lib/index.cjs +460 -497
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +461 -498
- package/lib/index.js.map +1 -1
- package/lib/react/VGrid.d.ts +3 -3
- package/lib/react/Virtualizer.d.ts +2 -2
- package/lib/react/WindowVirtualizer.d.ts +2 -2
- package/lib/solid/Virtualizer.d.ts +2 -2
- package/lib/solid/WindowVirtualizer.d.ts +2 -2
- package/lib/solid/index.cjs +262 -289
- package/lib/solid/index.cjs.map +1 -1
- package/lib/solid/index.js +273 -298
- package/lib/solid/index.js.map +1 -1
- package/lib/solid/index.jsx +160 -220
- package/lib/solid/index.jsx.map +1 -1
- package/lib/svelte/ListItem.svelte +1 -1
- package/lib/svelte/Virtualizer.svelte +12 -4
- package/lib/svelte/Virtualizer.type.d.ts +2 -2
- package/lib/svelte/WindowVirtualizer.svelte +12 -4
- package/lib/svelte/WindowVirtualizer.type.d.ts +2 -2
- package/lib/svelte/utils.d.ts +2 -0
- package/lib/svelte/utils.js +4 -1
- package/lib/svelte/utils.js.map +1 -1
- package/lib/vue/Virtualizer.d.ts +2 -2
- package/lib/vue/WindowVirtualizer.d.ts +2 -2
- package/lib/vue/index.cjs +365 -415
- package/lib/vue/index.cjs.map +1 -1
- package/lib/vue/index.js +316 -365
- package/lib/vue/index.js.map +1 -1
- package/package.json +3 -4
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { onMount, onDestroy } from "svelte";
|
|
3
3
|
import {
|
|
4
4
|
ACTION_ITEMS_LENGTH_CHANGE,
|
|
5
|
+
type ItemsRange,
|
|
5
6
|
type StateVersion,
|
|
6
7
|
UPDATE_SCROLL_END_EVENT,
|
|
7
8
|
UPDATE_SCROLL_EVENT,
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
createWindowDriver,
|
|
13
14
|
scrollToIndex as _scrollToIndex,
|
|
14
15
|
} from "../core/index.js";
|
|
15
|
-
import { defaultGetKey, styleToString } from "./utils.js";
|
|
16
|
+
import { defaultGetKey, isSameRange, styleToString } from "./utils.js";
|
|
16
17
|
import ListItem from "./ListItem.svelte";
|
|
17
18
|
import type {
|
|
18
19
|
WindowVirtualizerHandle,
|
|
@@ -55,10 +56,17 @@
|
|
|
55
56
|
|
|
56
57
|
let stateVersion: StateVersion = $state(store.$getStateVersion());
|
|
57
58
|
|
|
58
|
-
let
|
|
59
|
+
let prevRange: ItemsRange | undefined;
|
|
60
|
+
let range = $derived.by(() => {
|
|
61
|
+
stateVersion;
|
|
62
|
+
const next = store.$getRange(bufferSize);
|
|
63
|
+
if (prevRange && isSameRange(prevRange, next)) {
|
|
64
|
+
return prevRange;
|
|
65
|
+
}
|
|
66
|
+
return (prevRange = next);
|
|
67
|
+
});
|
|
59
68
|
let isScrolling = $derived(stateVersion && store.$isScrolling());
|
|
60
69
|
let totalSize = $derived(stateVersion && store.$getTotalSize());
|
|
61
|
-
let negative = $derived(stateVersion && driver.$isNegative());
|
|
62
70
|
|
|
63
71
|
let indexes = $derived.by(() => {
|
|
64
72
|
// https://github.com/inokawa/virtua/pull/847
|
|
@@ -139,7 +147,7 @@
|
|
|
139
147
|
{item}
|
|
140
148
|
{index}
|
|
141
149
|
as="div"
|
|
142
|
-
offset={stateVersion && store.$getItemOffset(index
|
|
150
|
+
offset={stateVersion && store.$getItemOffset(index)}
|
|
143
151
|
hide={stateVersion && store.$isUnmeasuredItem(index)}
|
|
144
152
|
{horizontal}
|
|
145
153
|
{isSSR}
|
|
@@ -65,11 +65,11 @@ export interface WindowVirtualizerHandle {
|
|
|
65
65
|
*/
|
|
66
66
|
getCache: () => CacheSnapshot;
|
|
67
67
|
/**
|
|
68
|
-
* Get current scrollTop, or scrollLeft if horizontal: true.
|
|
68
|
+
* Get current scrollTop, or scrollLeft if horizontal: true. Always positive even in RTL.
|
|
69
69
|
*/
|
|
70
70
|
getScrollOffset: () => number;
|
|
71
71
|
/**
|
|
72
|
-
* Get current
|
|
72
|
+
* Get current clientHeight of the document, or clientWidth if horizontal: true.
|
|
73
73
|
*/
|
|
74
74
|
getViewportSize: () => number;
|
|
75
75
|
/**
|
package/lib/svelte/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ItemsRange } from '../core/index.js';
|
|
1
2
|
export declare const styleToString: (obj: Record<string, string | undefined>) => string;
|
|
3
|
+
export declare const isSameRange: (prev: ItemsRange, next: ItemsRange) => boolean;
|
|
2
4
|
export declare const defaultGetKey: (_data: unknown, i: number) => string;
|
|
3
5
|
/**
|
|
4
6
|
* A function that provides properties/attributes for item element
|
package/lib/svelte/utils.js
CHANGED
|
@@ -6,8 +6,11 @@ var styleToString = (obj) => {
|
|
|
6
6
|
return acc + `${k}:${value};`;
|
|
7
7
|
}, "");
|
|
8
8
|
};
|
|
9
|
+
var isSameRange = (prev, next) => {
|
|
10
|
+
return prev[0] === next[0] && prev[1] === next[1];
|
|
11
|
+
};
|
|
9
12
|
var defaultGetKey = (_data, i) => "_" + i;
|
|
10
13
|
//#endregion
|
|
11
|
-
export { defaultGetKey, styleToString };
|
|
14
|
+
export { defaultGetKey, isSameRange, styleToString };
|
|
12
15
|
|
|
13
16
|
//# sourceMappingURL=utils.js.map
|
package/lib/svelte/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/svelte/utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/svelte/utils.ts"],"sourcesContent":["import type { ItemsRange } from \"../core/index.js\";\n\nexport const styleToString = (\n obj: Record<string, string | undefined>,\n): string => {\n return Object.keys(obj).reduce((acc, k) => {\n const value = obj[k];\n if (value == null) {\n return acc;\n }\n return acc + `${k}:${value};`;\n }, \"\");\n};\n\nexport const isSameRange = (prev: ItemsRange, next: ItemsRange): boolean => {\n return prev[0] === next[0] && prev[1] === next[1];\n};\n\nexport const defaultGetKey = (_data: unknown, i: number) => \"_\" + i;\n\n/**\n * @internal\n */\nexport type ItemAttrs = {\n [key: string]: any;\n style?: Record<string, string | undefined>;\n class?: string;\n};\n\n/**\n * A function that provides properties/attributes for item element\n */\nexport type ItemProps<T = unknown> = (payload: {\n item: T;\n index: number;\n}) => ItemAttrs | undefined;\n"],"mappings":";AAEA,IAAa,iBACX,QACW;CACX,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,QAAQ,KAAK,MAAM;EACzC,MAAM,QAAQ,IAAI;EAClB,IAAI,SAAS,MACX,OAAO;EAET,OAAO,MAAM,GAAG,EAAE,GAAG,MAAM;CAC7B,GAAG,EAAE;AACP;AAEA,IAAa,eAAe,MAAkB,SAA8B;CAC1E,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,OAAO,KAAK;AACjD;AAEA,IAAa,iBAAiB,OAAgB,MAAc,MAAM"}
|
package/lib/vue/Virtualizer.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ export interface VirtualizerHandle {
|
|
|
95
95
|
*/
|
|
96
96
|
readonly cache: CacheSnapshot;
|
|
97
97
|
/**
|
|
98
|
-
* Get current scrollTop, or scrollLeft if horizontal: true.
|
|
98
|
+
* Get current scrollTop, or scrollLeft if horizontal: true. Always positive even in RTL.
|
|
99
99
|
*/
|
|
100
100
|
readonly scrollOffset: number;
|
|
101
101
|
/**
|
|
@@ -103,7 +103,7 @@ export interface VirtualizerHandle {
|
|
|
103
103
|
*/
|
|
104
104
|
readonly scrollSize: number;
|
|
105
105
|
/**
|
|
106
|
-
* Get current
|
|
106
|
+
* Get current clientHeight, or clientWidth if horizontal: true.
|
|
107
107
|
*/
|
|
108
108
|
readonly viewportSize: number;
|
|
109
109
|
/**
|
|
@@ -75,11 +75,11 @@ export interface WindowVirtualizerHandle {
|
|
|
75
75
|
*/
|
|
76
76
|
readonly cache: CacheSnapshot;
|
|
77
77
|
/**
|
|
78
|
-
* Get current scrollTop, or scrollLeft if horizontal: true.
|
|
78
|
+
* Get current scrollTop, or scrollLeft if horizontal: true. Always positive even in RTL.
|
|
79
79
|
*/
|
|
80
80
|
readonly scrollOffset: number;
|
|
81
81
|
/**
|
|
82
|
-
* Get current
|
|
82
|
+
* Get current clientHeight of the document, or clientWidth if horizontal: true.
|
|
83
83
|
*/
|
|
84
84
|
readonly viewportSize: number;
|
|
85
85
|
/**
|