@tanstack/svelte-virtual 3.13.56 → 3.13.58
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/dist/index.js +13 -1
- package/package.json +2 -2
- package/src/index.ts +12 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Virtualizer, elementScroll, observeElementOffset, observeElementRect, observeWindowOffset, observeWindowRect, windowScroll, } from '@tanstack/virtual-core';
|
|
2
|
+
import { tick } from 'svelte';
|
|
2
3
|
import { derived, writable } from 'svelte/store';
|
|
3
4
|
export * from '@tanstack/virtual-core';
|
|
4
5
|
function createVirtualizerBase(initialOptions) {
|
|
@@ -30,7 +31,18 @@ function createVirtualizerBase(initialOptions) {
|
|
|
30
31
|
};
|
|
31
32
|
virtualizerWritable = writable(virtualizer, () => {
|
|
32
33
|
setOptions({});
|
|
33
|
-
|
|
34
|
+
let subscribed = true;
|
|
35
|
+
// The store is usually subscribed before `bind:this` assigns the scroll
|
|
36
|
+
// element, so read it again once Svelte has updated the DOM.
|
|
37
|
+
tick().then(() => {
|
|
38
|
+
if (subscribed)
|
|
39
|
+
virtualizer._willUpdate();
|
|
40
|
+
});
|
|
41
|
+
const cleanup = virtualizer._didMount();
|
|
42
|
+
return () => {
|
|
43
|
+
subscribed = false;
|
|
44
|
+
cleanup();
|
|
45
|
+
};
|
|
34
46
|
});
|
|
35
47
|
return derived(virtualizerWritable, (instance) => Object.assign(instance, { setOptions }));
|
|
36
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-virtual",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.58",
|
|
4
4
|
"description": "Headless UI for virtualizing scrollable elements in Svelte",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"src"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@tanstack/virtual-core": "3.19.
|
|
44
|
+
"@tanstack/virtual-core": "3.19.17"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@sveltejs/package": "^2.3.11",
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
observeWindowRect,
|
|
8
8
|
windowScroll,
|
|
9
9
|
} from '@tanstack/virtual-core'
|
|
10
|
+
import { tick } from 'svelte'
|
|
10
11
|
import { derived, writable } from 'svelte/store'
|
|
11
12
|
import type { PartialKeys, VirtualizerOptions } from '@tanstack/virtual-core'
|
|
12
13
|
import type { Readable, Writable } from 'svelte/store'
|
|
@@ -64,7 +65,17 @@ function createVirtualizerBase<
|
|
|
64
65
|
|
|
65
66
|
virtualizerWritable = writable(virtualizer, () => {
|
|
66
67
|
setOptions({})
|
|
67
|
-
|
|
68
|
+
let subscribed = true
|
|
69
|
+
// The store is usually subscribed before `bind:this` assigns the scroll
|
|
70
|
+
// element, so read it again once Svelte has updated the DOM.
|
|
71
|
+
tick().then(() => {
|
|
72
|
+
if (subscribed) virtualizer._willUpdate()
|
|
73
|
+
})
|
|
74
|
+
const cleanup = virtualizer._didMount()
|
|
75
|
+
return () => {
|
|
76
|
+
subscribed = false
|
|
77
|
+
cleanup()
|
|
78
|
+
}
|
|
68
79
|
})
|
|
69
80
|
|
|
70
81
|
return derived(virtualizerWritable, (instance) =>
|