@oxog/scrollex 1.0.0 → 1.1.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.
- package/CHANGELOG.md +86 -5
- package/README.md +30 -22
- package/dist/chunk-CIB3EBBJ.js +734 -0
- package/dist/chunk-CIB3EBBJ.js.map +1 -0
- package/dist/chunk-ND5PV5MU.cjs +747 -0
- package/dist/chunk-ND5PV5MU.cjs.map +1 -0
- package/dist/index.cjs +677 -961
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -784
- package/dist/index.d.ts +5 -784
- package/dist/index.js +651 -949
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.cjs +255 -766
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +61 -560
- package/dist/plugins/index.d.ts +61 -560
- package/dist/plugins/index.js +236 -761
- package/dist/plugins/index.js.map +1 -1
- package/dist/scroll-controller-D5AV1E2p.d.cts +809 -0
- package/dist/scroll-controller-D5AV1E2p.d.ts +809 -0
- package/package.json +30 -13
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,520 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface VirtualItem {
|
|
5
|
-
/** Index of the item in the data array */
|
|
6
|
-
index: number;
|
|
7
|
-
/** Unique key for React reconciliation */
|
|
8
|
-
key: string | number;
|
|
9
|
-
/** Offset from the start of the scroll container (px) */
|
|
10
|
-
start: number;
|
|
11
|
-
/** End position (start + size) */
|
|
12
|
-
end: number;
|
|
13
|
-
/** Size of the item (height for vertical, width for horizontal) */
|
|
14
|
-
size: number;
|
|
15
|
-
/** Lane/column index for grid and masonry layouts */
|
|
16
|
-
lane: number;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Represents the visible range of items.
|
|
20
|
-
*/
|
|
21
|
-
interface Range {
|
|
22
|
-
/** First visible item index */
|
|
23
|
-
startIndex: number;
|
|
24
|
-
/** Last visible item index */
|
|
25
|
-
endIndex: number;
|
|
26
|
-
/** First rendered item index (including overscan) */
|
|
27
|
-
overscanStartIndex: number;
|
|
28
|
-
/** Last rendered item index (including overscan) */
|
|
29
|
-
overscanEndIndex: number;
|
|
30
|
-
/** Alias for startIndex */
|
|
31
|
-
start?: number;
|
|
32
|
-
/** Alias for endIndex */
|
|
33
|
-
end?: number;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Represents scroll position in both axes.
|
|
37
|
-
*/
|
|
38
|
-
interface ScrollPosition {
|
|
39
|
-
scrollTop: number;
|
|
40
|
-
scrollLeft: number;
|
|
41
|
-
/** Normalized offset (scrollTop for vertical, scrollLeft for horizontal) */
|
|
42
|
-
offset?: number;
|
|
43
|
-
/** Scroll percentage (0-1) */
|
|
44
|
-
percentage?: number;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Represents the viewport dimensions.
|
|
48
|
-
*/
|
|
49
|
-
interface Viewport {
|
|
50
|
-
/** Visible width of the container */
|
|
51
|
-
width: number;
|
|
52
|
-
/** Visible height of the container */
|
|
53
|
-
height: number;
|
|
54
|
-
/** Total scrollable height */
|
|
55
|
-
scrollHeight: number;
|
|
56
|
-
/** Total scrollable width */
|
|
57
|
-
scrollWidth: number;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Scroll direction.
|
|
61
|
-
*/
|
|
62
|
-
type ScrollDirection = 'up' | 'down' | 'left' | 'right' | 'none';
|
|
63
|
-
/**
|
|
64
|
-
* Scroll behavior.
|
|
65
|
-
*/
|
|
66
|
-
type ScrollBehavior = 'auto' | 'smooth';
|
|
67
|
-
/**
|
|
68
|
-
* Alignment options for scrollToIndex.
|
|
69
|
-
*/
|
|
70
|
-
type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
|
|
71
|
-
/**
|
|
72
|
-
* Scroll event payload.
|
|
73
|
-
*/
|
|
74
|
-
interface ScrollEvent {
|
|
75
|
-
type: 'scroll';
|
|
76
|
-
scrollTop: number;
|
|
77
|
-
scrollLeft: number;
|
|
78
|
-
deltaY: number;
|
|
79
|
-
deltaX: number;
|
|
80
|
-
direction: ScrollDirection;
|
|
81
|
-
timestamp: number;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Scroll start event payload.
|
|
85
|
-
*/
|
|
86
|
-
interface ScrollStartEvent {
|
|
87
|
-
type: 'scroll-start';
|
|
88
|
-
scrollTop: number;
|
|
89
|
-
scrollLeft: number;
|
|
90
|
-
timestamp: number;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Scroll end event payload.
|
|
94
|
-
*/
|
|
95
|
-
interface ScrollEndEvent {
|
|
96
|
-
type: 'scroll-end';
|
|
97
|
-
scrollTop: number;
|
|
98
|
-
scrollLeft: number;
|
|
99
|
-
timestamp: number;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Visible range change event payload.
|
|
103
|
-
*/
|
|
104
|
-
interface VisibleRangeChangeEvent {
|
|
105
|
-
type: 'visible-range-change';
|
|
106
|
-
range: Range;
|
|
107
|
-
previousRange: Range | null;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Item measured event payload.
|
|
111
|
-
*/
|
|
112
|
-
interface ItemMeasuredEvent {
|
|
113
|
-
type: 'item-measured';
|
|
114
|
-
index: number;
|
|
115
|
-
height: number;
|
|
116
|
-
previousHeight: number | undefined;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Resize event payload.
|
|
120
|
-
*/
|
|
121
|
-
interface ResizeEvent {
|
|
122
|
-
type: 'resize';
|
|
123
|
-
viewport: Viewport;
|
|
124
|
-
previousViewport: Viewport | null;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Load more event payload.
|
|
128
|
-
*/
|
|
129
|
-
interface LoadMoreEvent {
|
|
130
|
-
type: 'load-more';
|
|
131
|
-
direction: 'forward' | 'backward';
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Items change event payload.
|
|
135
|
-
*/
|
|
136
|
-
interface ItemsChangeEvent {
|
|
137
|
-
type: 'items-change';
|
|
138
|
-
count: number;
|
|
139
|
-
previousCount: number;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Union of all kernel events.
|
|
143
|
-
*/
|
|
144
|
-
type KernelEvent = ScrollEvent | ScrollStartEvent | ScrollEndEvent | VisibleRangeChangeEvent | ItemMeasuredEvent | ResizeEvent | LoadMoreEvent | ItemsChangeEvent;
|
|
145
|
-
/**
|
|
146
|
-
* Event handler function type.
|
|
147
|
-
*/
|
|
148
|
-
type EventHandler<T = KernelEvent> = (event: T) => void;
|
|
149
|
-
/**
|
|
150
|
-
* Unsubscribe function returned by event subscriptions.
|
|
151
|
-
*/
|
|
152
|
-
type Unsubscribe = () => void;
|
|
153
|
-
/**
|
|
154
|
-
* Options for scroll operations.
|
|
155
|
-
*/
|
|
156
|
-
interface ScrollOptions {
|
|
157
|
-
/** Scroll behavior */
|
|
158
|
-
behavior?: ScrollBehavior;
|
|
159
|
-
/** Duration for smooth scroll (ms) */
|
|
160
|
-
duration?: number;
|
|
161
|
-
/** Easing function for smooth scroll */
|
|
162
|
-
easing?: EasingFunction;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Options for scrollToIndex operations.
|
|
166
|
-
*/
|
|
167
|
-
interface ScrollToIndexOptions extends ScrollOptions {
|
|
168
|
-
/** Alignment of the item in the viewport */
|
|
169
|
-
align?: ScrollAlignment;
|
|
170
|
-
/** Additional offset (px) */
|
|
171
|
-
offset?: number;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Easing function type.
|
|
175
|
-
*/
|
|
176
|
-
type EasingFunction = (t: number) => number;
|
|
177
|
-
/**
|
|
178
|
-
* Plugin type - core plugins are always loaded, optional are loaded on demand.
|
|
179
|
-
*/
|
|
180
|
-
type PluginType = 'core' | 'optional';
|
|
181
|
-
/**
|
|
182
|
-
* Plugin hooks interface.
|
|
183
|
-
*/
|
|
184
|
-
interface PluginHooks {
|
|
185
|
-
/** Called on scroll */
|
|
186
|
-
onScroll?: (event: ScrollEvent) => void;
|
|
187
|
-
/** Called when scroll starts */
|
|
188
|
-
onScrollStart?: (event: ScrollStartEvent) => void;
|
|
189
|
-
/** Called when scroll ends */
|
|
190
|
-
onScrollEnd?: (event: ScrollEndEvent) => void;
|
|
191
|
-
/** Called when visible range changes */
|
|
192
|
-
onVisibleRangeChange?: (range: Range, previousRange: Range | null) => void;
|
|
193
|
-
/** Called when an item is measured */
|
|
194
|
-
onItemMeasured?: (index: number, height: number) => void;
|
|
195
|
-
/** Called on viewport resize */
|
|
196
|
-
onResize?: (viewport: Viewport) => void;
|
|
197
|
-
/** Called when load more is triggered */
|
|
198
|
-
onLoadMore?: (direction: 'forward' | 'backward') => void;
|
|
199
|
-
/** Called when item count changes */
|
|
200
|
-
onItemsChange?: (count: number, previousCount: number) => void;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Plugin metadata.
|
|
204
|
-
*/
|
|
205
|
-
interface PluginInfo {
|
|
206
|
-
name: string;
|
|
207
|
-
version: string;
|
|
208
|
-
type: PluginType;
|
|
209
|
-
enabled: boolean;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Plugin interface.
|
|
213
|
-
*/
|
|
214
|
-
interface Plugin {
|
|
215
|
-
/** Unique plugin name */
|
|
216
|
-
name: string;
|
|
217
|
-
/** Plugin version */
|
|
218
|
-
version: string;
|
|
219
|
-
/** Plugin type (core or optional) */
|
|
220
|
-
type: PluginType;
|
|
221
|
-
/** Install plugin into kernel */
|
|
222
|
-
install?(kernel: Kernel): void;
|
|
223
|
-
/** Uninstall plugin */
|
|
224
|
-
uninstall?(): void;
|
|
225
|
-
/** Plugin hooks */
|
|
226
|
-
hooks?: PluginHooks;
|
|
227
|
-
/** Public API exposed by the plugin */
|
|
228
|
-
api?: any;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Kernel configuration options.
|
|
232
|
-
*/
|
|
233
|
-
interface KernelOptions {
|
|
234
|
-
/** Total number of items */
|
|
235
|
-
itemCount: number;
|
|
236
|
-
/** Estimated height of items (used before measurement) */
|
|
237
|
-
estimatedItemHeight: number;
|
|
238
|
-
/** Number of extra items to render outside viewport */
|
|
239
|
-
overscan: number;
|
|
240
|
-
/** Scroll direction */
|
|
241
|
-
direction: 'vertical' | 'horizontal';
|
|
242
|
-
/** Function to get item key */
|
|
243
|
-
getItemKey?: (index: number) => string | number;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Kernel interface - the core of the virtualization engine.
|
|
247
|
-
*/
|
|
248
|
-
interface Kernel {
|
|
249
|
-
/** Register a plugin */
|
|
250
|
-
register(plugin: Plugin): void;
|
|
251
|
-
/** Unregister a plugin by name */
|
|
252
|
-
unregister(pluginName: string): void;
|
|
253
|
-
/** Get a plugin by name */
|
|
254
|
-
getPlugin<T extends Plugin>(name: string): T | undefined;
|
|
255
|
-
/** List all registered plugins */
|
|
256
|
-
listPlugins(): PluginInfo[];
|
|
257
|
-
/** Get current scroll position */
|
|
258
|
-
getScrollPosition(): ScrollPosition;
|
|
259
|
-
/** Set scroll position directly */
|
|
260
|
-
setScrollPosition(position: ScrollPosition): void;
|
|
261
|
-
/** Scroll to offset */
|
|
262
|
-
scrollTo(offset: number, options?: ScrollOptions): void;
|
|
263
|
-
/** Scroll to item index */
|
|
264
|
-
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
265
|
-
/** Get viewport dimensions */
|
|
266
|
-
getViewport(): Viewport;
|
|
267
|
-
/** Get visible range */
|
|
268
|
-
getVisibleRange(): Range;
|
|
269
|
-
/** Get render range (including overscan) */
|
|
270
|
-
getRenderRange(): Range;
|
|
271
|
-
/** Measure an item's size */
|
|
272
|
-
measureItem(index: number, size: number): void;
|
|
273
|
-
/** Get cached height for an item */
|
|
274
|
-
getCachedHeight(index: number): number | undefined;
|
|
275
|
-
/** Invalidate measurement for an item */
|
|
276
|
-
invalidateMeasurement(index: number): void;
|
|
277
|
-
/** Invalidate all measurements */
|
|
278
|
-
invalidateAllMeasurements(): void;
|
|
279
|
-
/** Get estimated item height */
|
|
280
|
-
getEstimatedHeight(): number;
|
|
281
|
-
/** Get item offset */
|
|
282
|
-
getItemOffset(index: number): number;
|
|
283
|
-
/** Emit an event */
|
|
284
|
-
emit(event: KernelEvent): void;
|
|
285
|
-
/** Subscribe to an event type */
|
|
286
|
-
on<T extends KernelEvent>(eventType: T['type'], handler: EventHandler<T>): Unsubscribe;
|
|
287
|
-
/** Unsubscribe from an event type */
|
|
288
|
-
off<T extends KernelEvent>(eventType: T['type'], handler: EventHandler<T>): void;
|
|
289
|
-
/** Update kernel configuration */
|
|
290
|
-
configure(options: Partial<KernelOptions>): void;
|
|
291
|
-
/** Get current configuration */
|
|
292
|
-
getOptions(): KernelOptions;
|
|
293
|
-
/** Check if currently scrolling */
|
|
294
|
-
isScrolling(): boolean;
|
|
295
|
-
/** Get item count */
|
|
296
|
-
getItemCount(): number;
|
|
297
|
-
/** Get total scroll size */
|
|
298
|
-
getTotalSize(): number;
|
|
299
|
-
/** Attach to a container element */
|
|
300
|
-
attach(container: HTMLElement): void;
|
|
301
|
-
/** Detach from container */
|
|
302
|
-
detach(): void;
|
|
303
|
-
/** Destroy the kernel */
|
|
304
|
-
destroy(): void;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Gap configuration for grid layouts.
|
|
308
|
-
*/
|
|
309
|
-
interface GridGap {
|
|
310
|
-
x: number;
|
|
311
|
-
y: number;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* List renderer plugin options.
|
|
316
|
-
*/
|
|
317
|
-
interface ListRendererOptions {
|
|
318
|
-
/** Get item key for React reconciliation */
|
|
319
|
-
getItemKey?: (index: number) => string | number;
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* List renderer plugin API.
|
|
323
|
-
*/
|
|
324
|
-
interface ListRendererAPI {
|
|
325
|
-
/** Get virtual items to render */
|
|
326
|
-
getVirtualItems(): VirtualItem[];
|
|
327
|
-
/** Get total scroll height */
|
|
328
|
-
getTotalHeight(): number;
|
|
329
|
-
/** Get start offset (for positioning) */
|
|
330
|
-
getStartOffset(): number;
|
|
331
|
-
/** Get end offset */
|
|
332
|
-
getEndOffset(): number;
|
|
333
|
-
/** Check if an item is visible */
|
|
334
|
-
isItemVisible(index: number): boolean;
|
|
335
|
-
/** Force recalculation */
|
|
336
|
-
recalculate(): void;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Creates a list renderer plugin.
|
|
340
|
-
* This is the core virtualization engine for list rendering.
|
|
341
|
-
*
|
|
342
|
-
* @param options - Plugin options
|
|
343
|
-
* @returns Plugin instance
|
|
344
|
-
*/
|
|
345
|
-
declare function listRendererPlugin(options?: ListRendererOptions): Plugin;
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Grid renderer plugin options.
|
|
349
|
-
*/
|
|
350
|
-
interface GridRendererOptions {
|
|
351
|
-
/** Number of columns or 'auto' for responsive */
|
|
352
|
-
columns: number | 'auto';
|
|
353
|
-
/** Minimum column width for auto columns */
|
|
354
|
-
minColumnWidth?: number;
|
|
355
|
-
/** Row height */
|
|
356
|
-
rowHeight: number;
|
|
357
|
-
/** Gap between items */
|
|
358
|
-
gap?: number | GridGap;
|
|
359
|
-
/** Get item key for React reconciliation */
|
|
360
|
-
getItemKey?: (index: number) => string | number;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Grid renderer plugin API.
|
|
364
|
-
*/
|
|
365
|
-
interface GridRendererAPI {
|
|
366
|
-
/** Get virtual items to render */
|
|
367
|
-
getVirtualItems(): VirtualItem[];
|
|
368
|
-
/** Get total scroll height */
|
|
369
|
-
getTotalHeight(): number;
|
|
370
|
-
/** Get number of columns */
|
|
371
|
-
getColumnCount(): number;
|
|
372
|
-
/** Get column width */
|
|
373
|
-
getColumnWidth(): number;
|
|
374
|
-
/** Get number of items per row */
|
|
375
|
-
getItemsPerRow(): number;
|
|
376
|
-
/** Get row count */
|
|
377
|
-
getRowCount(): number;
|
|
378
|
-
/** Force recalculation */
|
|
379
|
-
recalculate(): void;
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Creates a grid renderer plugin.
|
|
383
|
-
* Handles multi-column grid virtualization.
|
|
384
|
-
*
|
|
385
|
-
* @param options - Plugin options
|
|
386
|
-
* @returns Plugin instance
|
|
387
|
-
*/
|
|
388
|
-
declare function gridRendererPlugin(options: GridRendererOptions): Plugin;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Auto measurer plugin options.
|
|
392
|
-
*/
|
|
393
|
-
interface AutoMeasurerOptions {
|
|
394
|
-
/** Estimated item height for initial layout */
|
|
395
|
-
estimatedItemHeight?: number;
|
|
396
|
-
/** Whether to re-measure when item content resizes */
|
|
397
|
-
measureOnResize?: boolean;
|
|
398
|
-
/** Debounce time for resize measurements (ms) */
|
|
399
|
-
debounceMs?: number;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Auto measurer plugin API.
|
|
403
|
-
*/
|
|
404
|
-
interface AutoMeasurerAPI {
|
|
405
|
-
/** Measure an element and update cache */
|
|
406
|
-
measureElement(index: number, element: HTMLElement): number;
|
|
407
|
-
/** Get cached size for an index */
|
|
408
|
-
getCachedSize(index: number): number | undefined;
|
|
409
|
-
/** Invalidate measurement for an index */
|
|
410
|
-
invalidate(index: number): void;
|
|
411
|
-
/** Invalidate all measurements */
|
|
412
|
-
invalidateAll(): void;
|
|
413
|
-
/** Get the measurement cache */
|
|
414
|
-
getMeasurementCache(): Map<number, number>;
|
|
415
|
-
/** Observe an element for size changes */
|
|
416
|
-
observe(index: number, element: HTMLElement): void;
|
|
417
|
-
/** Stop observing an element */
|
|
418
|
-
unobserve(element: HTMLElement): void;
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Creates an auto measurer plugin.
|
|
422
|
-
* Handles automatic measurement of variable height items.
|
|
423
|
-
*
|
|
424
|
-
* @param options - Plugin options
|
|
425
|
-
* @returns Plugin instance
|
|
426
|
-
*/
|
|
427
|
-
declare function autoMeasurerPlugin(options?: AutoMeasurerOptions): Plugin;
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Load direction.
|
|
431
|
-
*/
|
|
432
|
-
type LoadDirection = 'forward' | 'backward';
|
|
433
|
-
/**
|
|
434
|
-
* Infinite loader plugin options.
|
|
435
|
-
*/
|
|
436
|
-
interface InfiniteLoaderOptions {
|
|
437
|
-
/** Pixels from edge to trigger load */
|
|
438
|
-
threshold?: number;
|
|
439
|
-
/** Items from edge to trigger load */
|
|
440
|
-
thresholdItems?: number;
|
|
441
|
-
/** Direction to load more */
|
|
442
|
-
direction?: LoadDirection | 'both';
|
|
443
|
-
/** Callback when more items should be loaded */
|
|
444
|
-
onLoadMore: (direction: LoadDirection) => void | Promise<void>;
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Infinite loader plugin API.
|
|
448
|
-
*/
|
|
449
|
-
interface InfiniteLoaderAPI {
|
|
450
|
-
/** Check if currently loading */
|
|
451
|
-
isLoading(): boolean;
|
|
452
|
-
/** Set loading state */
|
|
453
|
-
setLoading(loading: boolean): void;
|
|
454
|
-
/** Check if there are more items to load */
|
|
455
|
-
hasMore(): boolean;
|
|
456
|
-
/** Set whether there are more items */
|
|
457
|
-
setHasMore(hasMore: boolean): void;
|
|
458
|
-
/** Check if can load forward */
|
|
459
|
-
hasMoreForward(): boolean;
|
|
460
|
-
/** Set whether can load forward */
|
|
461
|
-
setHasMoreForward(hasMore: boolean): void;
|
|
462
|
-
/** Check if can load backward */
|
|
463
|
-
hasMoreBackward(): boolean;
|
|
464
|
-
/** Set whether can load backward */
|
|
465
|
-
setHasMoreBackward(hasMore: boolean): void;
|
|
466
|
-
/** Reset loading state */
|
|
467
|
-
reset(): void;
|
|
468
|
-
/** Trigger load manually */
|
|
469
|
-
triggerLoad(direction: LoadDirection): void;
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Creates an infinite loader plugin.
|
|
473
|
-
* Handles infinite scroll detection and triggering.
|
|
474
|
-
*
|
|
475
|
-
* @param options - Plugin options
|
|
476
|
-
* @returns Plugin instance
|
|
477
|
-
*/
|
|
478
|
-
declare function infiniteLoaderPlugin(options: InfiniteLoaderOptions): Plugin;
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* Scroll controller plugin options.
|
|
482
|
-
*/
|
|
483
|
-
interface ScrollControllerOptions {
|
|
484
|
-
/** Default scroll duration (ms) */
|
|
485
|
-
defaultDuration?: number;
|
|
486
|
-
/** Default easing function */
|
|
487
|
-
defaultEasing?: EasingFunction;
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Scroll controller plugin API.
|
|
491
|
-
*/
|
|
492
|
-
interface ScrollControllerAPI {
|
|
493
|
-
/** Scroll to an offset */
|
|
494
|
-
scrollTo(offset: number, options?: ScrollOptions): void;
|
|
495
|
-
/** Scroll to an item index */
|
|
496
|
-
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
497
|
-
/** Scroll to the top */
|
|
498
|
-
scrollToTop(options?: ScrollOptions): void;
|
|
499
|
-
/** Scroll to the bottom */
|
|
500
|
-
scrollToBottom(options?: ScrollOptions): void;
|
|
501
|
-
/** Get current scroll position */
|
|
502
|
-
getScrollPosition(): ScrollPosition;
|
|
503
|
-
/** Check if currently scrolling */
|
|
504
|
-
isScrolling(): boolean;
|
|
505
|
-
/** Check if animation is in progress */
|
|
506
|
-
isAnimating(): boolean;
|
|
507
|
-
/** Stop current scroll animation */
|
|
508
|
-
stopAnimation(): void;
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Creates a scroll controller plugin.
|
|
512
|
-
* Provides programmatic scroll control with smooth animations.
|
|
513
|
-
*
|
|
514
|
-
* @param options - Plugin options
|
|
515
|
-
* @returns Plugin instance
|
|
516
|
-
*/
|
|
517
|
-
declare function scrollControllerPlugin(options?: ScrollControllerOptions): Plugin;
|
|
1
|
+
import { VirtualItem, Plugin, ScrollPosition, Range } from '../index.js';
|
|
2
|
+
export { A as AutoMeasurerAPI, j as AutoMeasurerOptions, n as GridRendererAPI, o as GridRendererOptions, I as InfiniteLoaderAPI, p as InfiniteLoaderOptions, L as ListRendererAPI, u as ListRendererOptions, v as LoadDirection, H as ScrollControllerAPI, J as ScrollControllerOptions, a1 as autoMeasurerPlugin, a2 as gridRendererPlugin, a3 as infiniteLoaderPlugin, a4 as listRendererPlugin, a5 as scrollControllerPlugin } from '../scroll-controller-D5AV1E2p.js';
|
|
3
|
+
import 'react';
|
|
518
4
|
|
|
519
5
|
/**
|
|
520
6
|
* Masonry renderer plugin options.
|
|
@@ -561,22 +47,21 @@ interface MasonryRendererAPI {
|
|
|
561
47
|
*
|
|
562
48
|
* @example
|
|
563
49
|
* ```tsx
|
|
50
|
+
* import { createKernel } from '@oxog/scrollex'
|
|
564
51
|
* import { masonryRenderer } from '@oxog/scrollex/plugins'
|
|
565
52
|
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
* )}
|
|
579
|
-
* />
|
|
53
|
+
* // The plugin lays items out on a kernel; the VirtualMasonry component does this itself from its props
|
|
54
|
+
* const kernel = createKernel({ itemCount: images.length, estimatedItemHeight: 200 })
|
|
55
|
+
* const masonry = masonryRenderer({
|
|
56
|
+
* columns: 3,
|
|
57
|
+
* gap: 8,
|
|
58
|
+
* getItemHeight: (index, columnWidth) => {
|
|
59
|
+
* const item = images[index]
|
|
60
|
+
* return (item.height / item.width) * columnWidth
|
|
61
|
+
* },
|
|
62
|
+
* })
|
|
63
|
+
* kernel.register(masonry)
|
|
64
|
+
* const items = masonry.api.getVirtualItems()
|
|
580
65
|
* ```
|
|
581
66
|
*/
|
|
582
67
|
declare function masonryRenderer(options: MasonryRendererOptions): Plugin;
|
|
@@ -634,6 +119,7 @@ interface StickyHeadersAPI {
|
|
|
634
119
|
*
|
|
635
120
|
* <VirtualList
|
|
636
121
|
* data={groupedItems}
|
|
122
|
+
* itemHeight={40}
|
|
637
123
|
* plugins={[stickyHeaders({
|
|
638
124
|
* headerHeight: 40,
|
|
639
125
|
* isHeader: (index) => groupedItems[index].type === 'header',
|
|
@@ -720,6 +206,7 @@ interface KeyboardNavAPI {
|
|
|
720
206
|
*
|
|
721
207
|
* <VirtualList
|
|
722
208
|
* data={items}
|
|
209
|
+
* itemHeight={40}
|
|
723
210
|
* plugins={[keyboardNav({
|
|
724
211
|
* loop: true,
|
|
725
212
|
* orientation: 'vertical',
|
|
@@ -797,6 +284,7 @@ interface ScrollRestorationAPI {
|
|
|
797
284
|
*
|
|
798
285
|
* <VirtualList
|
|
799
286
|
* data={items}
|
|
287
|
+
* itemHeight={40}
|
|
800
288
|
* plugins={[scrollRestoration({
|
|
801
289
|
* key: 'my-list',
|
|
802
290
|
* storage: 'sessionStorage',
|
|
@@ -819,7 +307,7 @@ interface BidirectionalOptions {
|
|
|
819
307
|
stickToBottom?: boolean;
|
|
820
308
|
/** Threshold in pixels from bottom to activate stick behavior */
|
|
821
309
|
stickThreshold?: number;
|
|
822
|
-
/**
|
|
310
|
+
/** Declared, not implemented yet: call `adjustForPrepend` after prepending */
|
|
823
311
|
maintainPositionOnPrepend?: boolean;
|
|
824
312
|
/** Callback when load more is triggered */
|
|
825
313
|
onLoadMore?: (direction: 'forward' | 'backward') => void;
|
|
@@ -862,14 +350,13 @@ interface BidirectionalAPI {
|
|
|
862
350
|
* plugins={[bidirectional({
|
|
863
351
|
* stickToBottom: true,
|
|
864
352
|
* initialPosition: 'bottom',
|
|
865
|
-
*
|
|
353
|
+
* onLoadMore: (direction) => {
|
|
354
|
+
* if (direction === 'backward') loadOlderMessages()
|
|
355
|
+
* if (direction === 'forward') loadNewerMessages()
|
|
356
|
+
* },
|
|
866
357
|
* })]}
|
|
867
|
-
*
|
|
868
|
-
*
|
|
869
|
-
* if (direction === 'forward') loadNewerMessages()
|
|
870
|
-
* }}
|
|
871
|
-
* renderItem={({ item, measureRef }) => (
|
|
872
|
-
* <div ref={measureRef}>
|
|
358
|
+
* renderItem={({ item, style, measureRef }) => (
|
|
359
|
+
* <div ref={measureRef} style={style}>
|
|
873
360
|
* <Message message={item} />
|
|
874
361
|
* </div>
|
|
875
362
|
* )}
|
|
@@ -934,17 +421,28 @@ interface DragToReorderAPI {
|
|
|
934
421
|
/** Create drag handle props */
|
|
935
422
|
getDragHandleProps(index: number): DragHandleProps;
|
|
936
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* The parts of a drag event the plugin reads. The native DragEvent and React's DragEvent both satisfy it, so
|
|
426
|
+
* the handler props can be spread on a React element.
|
|
427
|
+
*/
|
|
428
|
+
interface DragEventLike {
|
|
429
|
+
clientX: number;
|
|
430
|
+
clientY: number;
|
|
431
|
+
dataTransfer: DataTransfer | null;
|
|
432
|
+
currentTarget: EventTarget | null;
|
|
433
|
+
preventDefault(): void;
|
|
434
|
+
}
|
|
937
435
|
/**
|
|
938
436
|
* Props for drag handle element.
|
|
939
437
|
*/
|
|
940
438
|
interface DragHandleProps {
|
|
941
439
|
draggable: boolean;
|
|
942
|
-
onDragStart: (event:
|
|
943
|
-
onDragEnd: (event:
|
|
944
|
-
onDragOver: (event:
|
|
945
|
-
onDragEnter: (event:
|
|
946
|
-
onDragLeave: (event:
|
|
947
|
-
onDrop: (event:
|
|
440
|
+
onDragStart: (event: DragEventLike) => void;
|
|
441
|
+
onDragEnd: (event: DragEventLike) => void;
|
|
442
|
+
onDragOver: (event: DragEventLike) => void;
|
|
443
|
+
onDragEnter: (event: DragEventLike) => void;
|
|
444
|
+
onDragLeave: (event: DragEventLike) => void;
|
|
445
|
+
onDrop: (event: DragEventLike) => void;
|
|
948
446
|
'data-drag-index': string;
|
|
949
447
|
'aria-grabbed': boolean;
|
|
950
448
|
}
|
|
@@ -961,20 +459,22 @@ interface DragHandleProps {
|
|
|
961
459
|
*
|
|
962
460
|
* const [items, setItems] = useState(initialItems)
|
|
963
461
|
*
|
|
462
|
+
* // Create the plugin once: it keeps the drag in progress, and its api hands out the props for the rows
|
|
463
|
+
* const dnd = useMemo(() => dragToReorder({
|
|
464
|
+
* onReorder: (fromIndex, toIndex) => setItems((current) => {
|
|
465
|
+
* const newItems = [...current]
|
|
466
|
+
* const [removed] = newItems.splice(fromIndex, 1)
|
|
467
|
+
* newItems.splice(toIndex, 0, removed)
|
|
468
|
+
* return newItems
|
|
469
|
+
* }),
|
|
470
|
+
* }), [])
|
|
471
|
+
*
|
|
964
472
|
* <VirtualList
|
|
965
473
|
* data={items}
|
|
966
|
-
*
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
* newItems.splice(toIndex, 0, removed)
|
|
971
|
-
* setItems(newItems)
|
|
972
|
-
* },
|
|
973
|
-
* })]}
|
|
974
|
-
* renderItem={({ item, index, dragHandleProps }) => (
|
|
975
|
-
* <Row item={item}>
|
|
976
|
-
* <DragHandle {...dragHandleProps} />
|
|
977
|
-
* </Row>
|
|
474
|
+
* itemHeight={48}
|
|
475
|
+
* plugins={[dnd]}
|
|
476
|
+
* renderItem={({ item, index, style }) => (
|
|
477
|
+
* <Row item={item} style={style} {...dnd.api.getDragHandleProps(index)} />
|
|
978
478
|
* )}
|
|
979
479
|
* />
|
|
980
480
|
* ```
|
|
@@ -1051,9 +551,9 @@ interface DebugPanelOptions {
|
|
|
1051
551
|
theme?: DebugPanelTheme;
|
|
1052
552
|
/** Show FPS counter */
|
|
1053
553
|
showFps?: boolean;
|
|
1054
|
-
/** Show viewport overlay */
|
|
554
|
+
/** Show viewport overlay. Declared, not implemented yet: the switch only changes a flag */
|
|
1055
555
|
showViewportOverlay?: boolean;
|
|
1056
|
-
/** Show item boundaries */
|
|
556
|
+
/** Show item boundaries. Declared, not implemented yet: the switch only changes a flag */
|
|
1057
557
|
showItemBoundaries?: boolean;
|
|
1058
558
|
/** Log events to console */
|
|
1059
559
|
logEvents?: boolean;
|
|
@@ -1134,4 +634,5 @@ interface DebugPanelOverlayProps {
|
|
|
1134
634
|
*/
|
|
1135
635
|
declare function DebugPanelOverlay({ plugin, className, style, }: DebugPanelOverlayProps): React.ReactElement | null;
|
|
1136
636
|
|
|
1137
|
-
export {
|
|
637
|
+
export { DebugPanelOverlay, bidirectional, debugPanel, dragToReorder, keyboardNav, masonryRenderer, scrollRestoration, stickyHeaders };
|
|
638
|
+
export type { BidirectionalAPI, BidirectionalOptions, DebugPanelAPI, DebugPanelOptions, DebugPanelOverlayProps, DebugPanelPosition, DebugPanelState, DebugPanelTab, DebugPanelTheme, DragAxis, DragEventLike, DragHandleProps, DragToReorderAPI, DragToReorderOptions, DropIndicatorStyle, EventLogEntry, KeyboardNavAPI, KeyboardNavOptions, KeyboardNavOrientation, MasonryRendererAPI, MasonryRendererOptions, PerformanceStats, SavedScrollState, ScrollRestorationAPI, ScrollRestorationOptions, ScrollRestorationStorage, StickyHeadersAPI, StickyHeadersOptions };
|