virtua 0.48.8 → 0.49.0

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.
@@ -1,126 +1,26 @@
1
1
  /** @jsxImportSource vue */
2
- import { type ComponentOptionsMixin, type SlotsType, type VNode, type PropType } from "vue";
3
- import { type VirtualizerHandle } from "./Virtualizer.js";
4
- import { type ItemProps } from "./utils.js";
5
- import { type CacheSnapshot } from "../core/index.js";
6
- interface VListHandle extends VirtualizerHandle {
2
+ import { type VNode, type PublicProps } from "vue";
3
+ import { VirtualizerProps, type VirtualizerHandle } from "./Virtualizer.js";
4
+ /**
5
+ * Methods of {@link VList}.
6
+ */
7
+ export interface VListHandle extends VirtualizerHandle {
7
8
  }
8
- export declare const VList: import("vue").DefineComponent<{
9
- /**
10
- * The data items rendered by this component.
11
- */
12
- data: {
13
- type: ArrayConstructor;
14
- required: true;
15
- };
16
- /**
17
- * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
18
- * @defaultValue 200
19
- */
20
- bufferSize: NumberConstructor;
21
- /**
22
- * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.
23
- *
24
- * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
25
- * - If set, you can opt out estimation and use the value as initial item size.
26
- */
27
- itemSize: NumberConstructor;
28
- /**
29
- * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
30
- */
31
- shift: BooleanConstructor;
32
- /**
33
- * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
34
- */
35
- horizontal: BooleanConstructor;
36
- /**
37
- * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.
38
- */
39
- ssrCount: NumberConstructor;
40
- /**
41
- * A function that provides properties/attributes for item element
42
- *
43
- * **This prop will be merged into `item` prop in the future**
44
- */
45
- itemProps: PropType<ItemProps>;
46
- /**
47
- * List of indexes that should be always mounted, even when off screen.
48
- */
49
- keepMounted: PropType<readonly number[]>;
50
- /**
51
- * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VirtualizerHandle.cache}.
52
- *
53
- * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**
54
- */
55
- cache: PropType<CacheSnapshot>;
56
- }, VListHandle, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
57
- /**
58
- * Callback invoked whenever scroll offset changes.
59
- * @param offset Current scrollTop, or scrollLeft if horizontal: true.
60
- */
61
- scroll: (offset: number) => void;
62
- /**
63
- * Callback invoked when scrolling stops.
64
- */
65
- scrollEnd: () => void;
66
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
67
- /**
68
- * The data items rendered by this component.
69
- */
70
- data: {
71
- type: ArrayConstructor;
72
- required: true;
9
+ /**
10
+ * Props of {@link VList}.
11
+ */
12
+ export interface VListProps<T = unknown> extends PublicProps, Pick<VirtualizerProps<T>, "data" | "bufferSize" | "itemSize" | "shift" | "horizontal" | "cache" | "ssrCount" | "itemProps" | "onScroll" | "onScrollEnd" | "keepMounted"> {
13
+ }
14
+ interface VListInstance<T = unknown> extends VListHandle {
15
+ $props: VListProps<T>;
16
+ $slots: {
17
+ default: (arg: {
18
+ item: T;
19
+ index: number;
20
+ }) => VNode[];
73
21
  };
74
- /**
75
- * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
76
- * @defaultValue 200
77
- */
78
- bufferSize: NumberConstructor;
79
- /**
80
- * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.
81
- *
82
- * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
83
- * - If set, you can opt out estimation and use the value as initial item size.
84
- */
85
- itemSize: NumberConstructor;
86
- /**
87
- * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
88
- */
89
- shift: BooleanConstructor;
90
- /**
91
- * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
92
- */
93
- horizontal: BooleanConstructor;
94
- /**
95
- * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.
96
- */
97
- ssrCount: NumberConstructor;
98
- /**
99
- * A function that provides properties/attributes for item element
100
- *
101
- * **This prop will be merged into `item` prop in the future**
102
- */
103
- itemProps: PropType<ItemProps>;
104
- /**
105
- * List of indexes that should be always mounted, even when off screen.
106
- */
107
- keepMounted: PropType<readonly number[]>;
108
- /**
109
- * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VirtualizerHandle.cache}.
110
- *
111
- * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**
112
- */
113
- cache: PropType<CacheSnapshot>;
114
- }>> & {
115
- onScroll?: ((offset: number) => any) | undefined;
116
- onScrollEnd?: (() => any) | undefined;
117
- }, {
118
- shift: boolean;
119
- horizontal: boolean;
120
- }, SlotsType<{
121
- default: (arg: {
122
- item: any;
123
- index: number;
124
- }) => VNode[];
125
- }>>;
22
+ }
23
+ export declare const VList: {
24
+ new <T = unknown>(props: VListProps<T>): VListInstance<T>;
25
+ };
126
26
  export {};
@@ -1,228 +1,145 @@
1
1
  /** @jsxImportSource vue */
2
- import { type VNode, type ComponentOptionsMixin, type SlotsType, type PropType, type NativeElements } from "vue";
2
+ import { type VNode, type PublicProps, type NativeElements } from "vue";
3
3
  import { type ScrollToIndexOpts, type CacheSnapshot } from "../core/index.js";
4
4
  import { type ItemProps } from "./utils.js";
5
- export interface VirtualizerHandle {
6
- /**
7
- * Get current {@link CacheSnapshot}.
8
- */
9
- readonly cache: CacheSnapshot;
10
- /**
11
- * Get current scrollTop, or scrollLeft if horizontal: true.
12
- */
13
- readonly scrollOffset: number;
14
- /**
15
- * Get current scrollHeight, or scrollWidth if horizontal: true.
16
- */
17
- readonly scrollSize: number;
18
- /**
19
- * Get current offsetHeight, or offsetWidth if horizontal: true.
20
- */
21
- readonly viewportSize: number;
22
- /**
23
- * Find nearest item index from offset.
24
- * @param offset offset in pixels from the start of the scroll container
25
- */
26
- findItemIndex(offset: number): number;
27
- /**
28
- * Get item offset from start.
29
- * @param index index of item
30
- */
31
- getItemOffset(index: number): number;
32
- /**
33
- * Get item size.
34
- * @param index index of item
35
- */
36
- getItemSize(index: number): number;
37
- /**
38
- * Scroll to the item specified by index.
39
- * @param index index of item
40
- * @param opts options
41
- */
42
- scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;
43
- /**
44
- * Scroll to the given offset.
45
- * @param offset offset from start
46
- */
47
- scrollTo(offset: number): void;
48
- /**
49
- * Scroll by the given offset.
50
- * @param offset offset from current position
51
- */
52
- scrollBy(offset: number): void;
53
- }
54
- export declare const Virtualizer: import("vue").DefineComponent<{
5
+ /**
6
+ * Props of {@link Virtualizer}.
7
+ */
8
+ export interface VirtualizerProps<T = unknown> extends PublicProps {
55
9
  /**
56
10
  * The data items rendered by this component.
57
11
  */
58
- data: {
59
- type: ArrayConstructor;
60
- required: true;
61
- };
12
+ data: T[];
62
13
  /**
63
14
  * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
64
15
  * @defaultValue 200
65
16
  */
66
- bufferSize: NumberConstructor;
17
+ bufferSize?: number;
67
18
  /**
68
19
  * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.
69
20
  *
70
21
  * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
71
22
  * - If set, you can opt out estimation and use the value as initial item size.
72
23
  */
73
- itemSize: NumberConstructor;
24
+ itemSize?: number;
74
25
  /**
75
26
  * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
76
27
  */
77
- shift: BooleanConstructor;
28
+ shift?: boolean;
78
29
  /**
79
30
  * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
80
31
  */
81
- horizontal: BooleanConstructor;
32
+ horizontal?: boolean;
82
33
  /**
83
34
  * The offset to the scrollable parent before virtualizer in pixels. If you put an element before virtualizer, you have to set its height to this prop.
84
35
  */
85
- startMargin: {
86
- type: NumberConstructor;
87
- default: number;
88
- };
36
+ startMargin?: number;
89
37
  /**
90
38
  * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.
91
39
  */
92
- ssrCount: NumberConstructor;
40
+ ssrCount?: number;
93
41
  /**
94
42
  * Reference to the scrollable element. The default will get the direct parent element of virtualizer.
95
43
  */
96
- scrollRef: PropType<HTMLElement>;
44
+ scrollRef?: HTMLElement;
97
45
  /**
98
46
  * Component or element type for container element.
99
47
  * @defaultValue "div"
100
48
  */
101
- as: {
102
- type: PropType<keyof NativeElements>;
103
- default: string;
104
- };
49
+ as?: keyof NativeElements;
105
50
  /**
106
51
  * Component or element type for item element.
107
52
  * @defaultValue "div"
108
53
  */
109
- item: {
110
- type: PropType<keyof NativeElements>;
111
- default: string;
112
- };
54
+ item?: keyof NativeElements;
113
55
  /**
114
56
  * A function that provides properties/attributes for item element
115
57
  *
116
58
  * **This prop will be merged into `item` prop in the future**
117
59
  */
118
- itemProps: PropType<ItemProps>;
60
+ itemProps?: ItemProps<T>;
119
61
  /**
120
62
  * List of indexes that should be always mounted, even when off screen.
121
63
  */
122
- keepMounted: PropType<readonly number[]>;
64
+ keepMounted?: readonly number[];
123
65
  /**
124
66
  * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VirtualizerHandle.cache}.
125
67
  *
126
68
  * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**
127
69
  */
128
- cache: PropType<CacheSnapshot>;
129
- }, VirtualizerHandle, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
70
+ cache?: CacheSnapshot;
130
71
  /**
131
72
  * Callback invoked whenever scroll offset changes.
132
73
  * @param offset Current scrollTop, or scrollLeft if horizontal: true.
133
74
  */
134
- scroll: (offset: number) => void;
75
+ onScroll?: (offset: number) => void;
135
76
  /**
136
77
  * Callback invoked when scrolling stops.
137
78
  */
138
- scrollEnd: () => void;
139
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
140
- /**
141
- * The data items rendered by this component.
142
- */
143
- data: {
144
- type: ArrayConstructor;
145
- required: true;
79
+ onScrollEnd?: () => void;
80
+ }
81
+ interface VirtualizerInstance<T = unknown> extends VirtualizerHandle {
82
+ $props: VirtualizerProps<T>;
83
+ $slots: {
84
+ default: (arg: {
85
+ item: T;
86
+ index: number;
87
+ }) => VNode[];
146
88
  };
89
+ }
90
+ /**
91
+ * Methods of {@link Virtualizer}.
92
+ */
93
+ export interface VirtualizerHandle {
147
94
  /**
148
- * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
149
- * @defaultValue 200
150
- */
151
- bufferSize: NumberConstructor;
152
- /**
153
- * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.
154
- *
155
- * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
156
- * - If set, you can opt out estimation and use the value as initial item size.
157
- */
158
- itemSize: NumberConstructor;
159
- /**
160
- * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
95
+ * Get current {@link CacheSnapshot}.
161
96
  */
162
- shift: BooleanConstructor;
97
+ readonly cache: CacheSnapshot;
163
98
  /**
164
- * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
99
+ * Get current scrollTop, or scrollLeft if horizontal: true.
165
100
  */
166
- horizontal: BooleanConstructor;
101
+ readonly scrollOffset: number;
167
102
  /**
168
- * The offset to the scrollable parent before virtualizer in pixels. If you put an element before virtualizer, you have to set its height to this prop.
103
+ * Get current scrollHeight, or scrollWidth if horizontal: true.
169
104
  */
170
- startMargin: {
171
- type: NumberConstructor;
172
- default: number;
173
- };
105
+ readonly scrollSize: number;
174
106
  /**
175
- * A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated. The minimum value is 0.
107
+ * Get current offsetHeight, or offsetWidth if horizontal: true.
176
108
  */
177
- ssrCount: NumberConstructor;
109
+ readonly viewportSize: number;
178
110
  /**
179
- * Reference to the scrollable element. The default will get the direct parent element of virtualizer.
111
+ * Find nearest item index from offset.
112
+ * @param offset offset in pixels from the start of the scroll container
180
113
  */
181
- scrollRef: PropType<HTMLElement>;
114
+ findItemIndex(offset: number): number;
182
115
  /**
183
- * Component or element type for container element.
184
- * @defaultValue "div"
116
+ * Get item offset from start.
117
+ * @param index index of item
185
118
  */
186
- as: {
187
- type: PropType<keyof NativeElements>;
188
- default: string;
189
- };
119
+ getItemOffset(index: number): number;
190
120
  /**
191
- * Component or element type for item element.
192
- * @defaultValue "div"
121
+ * Get item size.
122
+ * @param index index of item
193
123
  */
194
- item: {
195
- type: PropType<keyof NativeElements>;
196
- default: string;
197
- };
124
+ getItemSize(index: number): number;
198
125
  /**
199
- * A function that provides properties/attributes for item element
200
- *
201
- * **This prop will be merged into `item` prop in the future**
126
+ * Scroll to the item specified by index.
127
+ * @param index index of item
128
+ * @param opts options
202
129
  */
203
- itemProps: PropType<ItemProps>;
130
+ scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;
204
131
  /**
205
- * List of indexes that should be always mounted, even when off screen.
132
+ * Scroll to the given offset.
133
+ * @param offset offset from start
206
134
  */
207
- keepMounted: PropType<readonly number[]>;
135
+ scrollTo(offset: number): void;
208
136
  /**
209
- * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link VirtualizerHandle.cache}.
210
- *
211
- * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**
137
+ * Scroll by the given offset.
138
+ * @param offset offset from current position
212
139
  */
213
- cache: PropType<CacheSnapshot>;
214
- }>> & {
215
- onScroll?: ((offset: number) => any) | undefined;
216
- onScrollEnd?: (() => any) | undefined;
217
- }, {
218
- shift: boolean;
219
- horizontal: boolean;
220
- startMargin: number;
221
- as: keyof import("vue").IntrinsicElementAttributes;
222
- item: keyof import("vue").IntrinsicElementAttributes;
223
- }, SlotsType<{
224
- default: (arg: {
225
- item: any;
226
- index: number;
227
- }) => VNode[];
228
- }>>;
140
+ scrollBy(offset: number): void;
141
+ }
142
+ export declare const Virtualizer: {
143
+ new <T = unknown>(props: VirtualizerProps<T>): VirtualizerInstance<T>;
144
+ };
145
+ export {};
@@ -1,161 +1,107 @@
1
1
  /** @jsxImportSource vue */
2
- import { type VNode, type ComponentOptionsMixin, type SlotsType, type PropType, type NativeElements } from "vue";
2
+ import { type VNode, type PublicProps, type IntrinsicElementAttributes } from "vue";
3
3
  import { type ScrollToIndexOpts, type CacheSnapshot } from "../core/index.js";
4
- export interface WindowVirtualizerHandle {
5
- /**
6
- * Get current {@link CacheSnapshot}.
7
- */
8
- readonly cache: CacheSnapshot;
9
- /**
10
- * Get current scrollTop, or scrollLeft if horizontal: true.
11
- */
12
- readonly scrollOffset: number;
13
- /**
14
- * Get current offsetHeight, or offsetWidth if horizontal: true.
15
- */
16
- readonly viewportSize: number;
17
- /**
18
- * Find nearest item index from offset.
19
- * @param offset offset in pixels from the start of the scroll container
20
- */
21
- findItemIndex(offset: number): number;
22
- /**
23
- * Get item offset from start.
24
- * @param index index of item
25
- */
26
- getItemOffset(index: number): number;
27
- /**
28
- * Get item size.
29
- * @param index index of item
30
- */
31
- getItemSize(index: number): number;
32
- /**
33
- * Scroll to the item specified by index.
34
- * @param index index of item
35
- * @param opts options
36
- */
37
- scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;
38
- }
39
- export declare const WindowVirtualizer: import("vue").DefineComponent<{
4
+ /**
5
+ * Props of {@link WindowVirtualizer}.
6
+ */
7
+ export interface WindowVirtualizerProps<T = unknown> extends PublicProps {
40
8
  /**
41
9
  * The data items rendered by this component.
42
10
  */
43
- data: {
44
- type: ArrayConstructor;
45
- required: true;
46
- };
11
+ data: T[];
47
12
  /**
48
13
  * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
49
14
  * @defaultValue 200
50
15
  */
51
- bufferSize: NumberConstructor;
16
+ bufferSize?: number;
52
17
  /**
53
18
  * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.
54
19
  *
55
20
  * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
56
21
  * - If set, you can opt out estimation and use the value as initial item size.
57
22
  */
58
- itemSize: NumberConstructor;
23
+ itemSize?: number;
59
24
  /**
60
25
  * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
61
26
  */
62
- shift: BooleanConstructor;
27
+ shift?: boolean;
63
28
  /**
64
29
  * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
65
30
  */
66
- horizontal: BooleanConstructor;
31
+ horizontal?: boolean;
67
32
  /**
68
33
  * Component or element type for container element.
69
34
  * @defaultValue "div"
70
35
  */
71
- as: {
72
- type: PropType<keyof NativeElements>;
73
- default: string;
74
- };
36
+ as?: keyof IntrinsicElementAttributes;
75
37
  /**
76
38
  * Component or element type for item element.
77
39
  * @defaultValue "div"
78
40
  */
79
- item: {
80
- type: PropType<keyof NativeElements>;
81
- default: string;
82
- };
41
+ item?: keyof IntrinsicElementAttributes;
83
42
  /**
84
43
  * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link WindowVirtualizerHandle.cache}.
85
44
  *
86
45
  * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**
87
46
  */
88
- cache: PropType<CacheSnapshot>;
89
- }, void, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
47
+ cache?: CacheSnapshot;
90
48
  /**
91
49
  * Callback invoked whenever scroll offset changes.
92
50
  */
93
- scroll: () => void;
51
+ onScroll?: () => void;
94
52
  /**
95
53
  * Callback invoked when scrolling stops.
96
54
  */
97
- scrollEnd: () => void;
98
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
99
- /**
100
- * The data items rendered by this component.
101
- */
102
- data: {
103
- type: ArrayConstructor;
104
- required: true;
55
+ onScrollEnd?: () => void;
56
+ }
57
+ interface WindowVirtualizerInstance<T = unknown> extends WindowVirtualizerHandle {
58
+ $props: WindowVirtualizerProps<T>;
59
+ $slots: {
60
+ default: (arg: {
61
+ item: T;
62
+ index: number;
63
+ }) => VNode[];
105
64
  };
65
+ }
66
+ /**
67
+ * Methods of {@link WindowVirtualizer}.
68
+ */
69
+ export interface WindowVirtualizerHandle {
106
70
  /**
107
- * Extra item space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.
108
- * @defaultValue 200
71
+ * Get current {@link CacheSnapshot}.
109
72
  */
110
- bufferSize: NumberConstructor;
73
+ readonly cache: CacheSnapshot;
111
74
  /**
112
- * Item size hint for unmeasured items in pixels. It will help to reduce scroll jump when items are measured if used properly.
113
- *
114
- * - If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
115
- * - If set, you can opt out estimation and use the value as initial item size.
75
+ * Get current scrollTop, or scrollLeft if horizontal: true.
116
76
  */
117
- itemSize: NumberConstructor;
77
+ readonly scrollOffset: number;
118
78
  /**
119
- * While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.
79
+ * Get current offsetHeight, or offsetWidth if horizontal: true.
120
80
  */
121
- shift: BooleanConstructor;
81
+ readonly viewportSize: number;
122
82
  /**
123
- * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.
83
+ * Find nearest item index from offset.
84
+ * @param offset offset in pixels from the start of the scroll container
124
85
  */
125
- horizontal: BooleanConstructor;
86
+ findItemIndex(offset: number): number;
126
87
  /**
127
- * Component or element type for container element.
128
- * @defaultValue "div"
88
+ * Get item offset from start.
89
+ * @param index index of item
129
90
  */
130
- as: {
131
- type: PropType<keyof NativeElements>;
132
- default: string;
133
- };
91
+ getItemOffset(index: number): number;
134
92
  /**
135
- * Component or element type for item element.
136
- * @defaultValue "div"
93
+ * Get item size.
94
+ * @param index index of item
137
95
  */
138
- item: {
139
- type: PropType<keyof NativeElements>;
140
- default: string;
141
- };
96
+ getItemSize(index: number): number;
142
97
  /**
143
- * You can restore cache by passing a {@link CacheSnapshot} on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from {@link WindowVirtualizerHandle.cache}.
144
- *
145
- * **The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.**
98
+ * Scroll to the item specified by index.
99
+ * @param index index of item
100
+ * @param opts options
146
101
  */
147
- cache: PropType<CacheSnapshot>;
148
- }>> & {
149
- onScroll?: (() => any) | undefined;
150
- onScrollEnd?: (() => any) | undefined;
151
- }, {
152
- shift: boolean;
153
- horizontal: boolean;
154
- as: keyof import("vue").IntrinsicElementAttributes;
155
- item: keyof import("vue").IntrinsicElementAttributes;
156
- }, SlotsType<{
157
- default: (arg: {
158
- item: any;
159
- index: number;
160
- }) => VNode[];
161
- }>>;
102
+ scrollToIndex(index: number, opts?: ScrollToIndexOpts): void;
103
+ }
104
+ export declare const WindowVirtualizer: {
105
+ new <T = unknown>(props: WindowVirtualizerProps<T>): WindowVirtualizerInstance<T>;
106
+ };
107
+ export {};