vlist 2.3.0 → 2.4.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.
@@ -1,121 +0,0 @@
1
- /**
2
- * vlist - Scroll Controller
3
- * Handles both native scrolling and manual wheel-based scrolling for compressed lists
4
- *
5
- * When compression is active (large lists exceeding browser height limits),
6
- * we switch from native scrolling to manual wheel event handling.
7
- * This allows smooth scrolling through millions of items.
8
- */
9
- import type { CompressionState } from "../../rendering/scale";
10
- /** Scroll direction */
11
- export type ScrollDirection = "up" | "down" | "left" | "right";
12
- /** Scroll event data */
13
- export interface ScrollEventData {
14
- scrollTop: number;
15
- direction: ScrollDirection;
16
- velocity: number;
17
- }
18
- /** Scroll controller configuration */
19
- export interface ScrollControllerConfig {
20
- /** Enable compressed scroll mode (manual wheel handling) */
21
- compressed?: boolean;
22
- /** Compression state for calculating bounds */
23
- compression?: CompressionState;
24
- /**
25
- * External scroll element for window/document scrolling.
26
- * When set, the controller listens to this element's scroll events
27
- * and computes list-relative positions from the viewport's bounding rect.
28
- */
29
- scrollElement?: Window;
30
- /** Allow mouse wheel to scroll (default: true) */
31
- wheel?: boolean;
32
- /** Wheel sensitivity multiplier (default: 1) */
33
- sensitivity?: number;
34
- /** Enable smooth scrolling interpolation */
35
- smoothing?: boolean;
36
- /** Scroll idle detection timeout in ms (default: 150) */
37
- idleTimeout?: number;
38
- /**
39
- * Primary axis is X (horizontal scrolling mode).
40
- * When true, the controller reads scrollLeft instead of scrollTop,
41
- * uses clientWidth instead of clientHeight, and maps wheel deltaX.
42
- */
43
- isX?: boolean;
44
- /** Callback when scroll position changes */
45
- onScroll?: (data: ScrollEventData) => void;
46
- /** Callback when scrolling becomes idle */
47
- onIdle?: () => void;
48
- }
49
- /** Scroll controller instance */
50
- export interface ScrollController {
51
- /** Get current scroll position */
52
- getScrollTop: () => number;
53
- /** Set scroll position */
54
- scrollTo: (position: number, smooth?: boolean) => void;
55
- /** Scroll by delta */
56
- scrollBy: (delta: number) => void;
57
- /** Check if at top */
58
- isAtTop: () => boolean;
59
- /** Check if at bottom */
60
- isAtBottom: (threshold?: number) => boolean;
61
- /** Get scroll percentage (0-1) */
62
- getScrollPercentage: () => number;
63
- /** Get current scroll velocity (px/ms, absolute value) */
64
- getVelocity: () => number;
65
- /**
66
- * Check if the velocity tracker is actively tracking with enough samples.
67
- * Returns false during ramp-up (first few frames of a new scroll gesture)
68
- * when the tracker doesn't have enough samples yet.
69
- */
70
- isTracking: () => boolean;
71
- /** Check if currently scrolling */
72
- isScrolling: () => boolean;
73
- /** Update configuration (e.g., when compression state changes) */
74
- updateConfig: (config: Partial<ScrollControllerConfig>) => void;
75
- /** Enable compressed mode */
76
- enableCompression: (compression: CompressionState) => void;
77
- /** Disable compressed mode (revert to native scroll) */
78
- disableCompression: () => void;
79
- /** Check if compressed mode is active */
80
- isCompressed: () => boolean;
81
- /** Check if in window scroll mode */
82
- isWindowMode: () => boolean;
83
- /**
84
- * Update the container height used for scroll calculations.
85
- * In window mode, call this when the window resizes.
86
- */
87
- updateContainerHeight: (height: number) => void;
88
- /** Destroy and cleanup */
89
- destroy: () => void;
90
- }
91
- /**
92
- * Create a scroll controller for a viewport element
93
- *
94
- * Supports two modes:
95
- * 1. Native scrolling (default) - uses browser's built-in scroll
96
- * 2. Compressed scrolling - manual wheel handling for large lists
97
- */
98
- export declare const createScrollController: (viewport: HTMLElement, config?: ScrollControllerConfig) => ScrollController;
99
- /**
100
- * Throttle scroll handler using requestAnimationFrame
101
- */
102
- export declare const rafThrottle: <T extends (...args: any[]) => void>(fn: T) => ((...args: Parameters<T>) => void) & {
103
- cancel: () => void;
104
- };
105
- /**
106
- * Check if scroll position is at bottom
107
- */
108
- export declare const isAtBottom: (scrollTop: number, scrollHeight: number, clientHeight: number, threshold?: number) => boolean;
109
- /**
110
- * Check if scroll position is at top
111
- */
112
- export declare const isAtTop: (scrollTop: number, threshold?: number) => boolean;
113
- /**
114
- * Get scroll percentage (0-1)
115
- */
116
- export declare const getScrollPercentage: (scrollTop: number, scrollHeight: number, clientHeight: number) => number;
117
- /**
118
- * Check if a range is visible in the scroll viewport
119
- */
120
- export declare const isRangeVisible: (rangeStart: number, rangeEnd: number, visibleStart: number, visibleEnd: number) => boolean;
121
- //# sourceMappingURL=controller.d.ts.map
@@ -1,52 +0,0 @@
1
- /**
2
- * vlist - Measured Size Cache
3
- * Auto-measurement support for items with unknown sizes (Mode B)
4
- *
5
- * Wraps the existing variable SizeCache with measurement tracking.
6
- * Once an item is measured, it behaves identically to Mode A (known size).
7
- * Unmeasured items use the estimated size as a fallback.
8
- *
9
- * Fully axis-neutral: works identically for vertical (estimatedHeight)
10
- * and horizontal (estimatedWidth) orientations. This cache stores plain
11
- * numbers representing the main-axis dimension — it never knows whether
12
- * those numbers are heights or widths. The axis-specific translation
13
- * happens in builder/core.ts at the DOM boundary.
14
- *
15
- * Implements the SizeCache interface so all downstream code
16
- * (viewport, scale, features) works unchanged.
17
- */
18
- import type { SizeCache } from "./sizes";
19
- /** Extended SizeCache with measurement tracking */
20
- export interface MeasuredSizeCache extends SizeCache {
21
- /** Record actual measured size for an item */
22
- setMeasuredSize(index: number, size: number): void;
23
- /** Check if an item has been measured */
24
- isMeasured(index: number): boolean;
25
- /** Get the estimated size (used for unmeasured items) */
26
- getEstimatedSize(): number;
27
- /** Number of items that have been measured */
28
- measuredCount(): number;
29
- }
30
- /**
31
- * Create a measured size cache for auto-measurement (Mode B)
32
- *
33
- * Works for both orientations:
34
- * - Vertical: estimatedSize = estimatedHeight, measures block size
35
- * - Horizontal: estimatedSize = estimatedWidth, measures inline size
36
- *
37
- * The cache itself is axis-neutral — it only stores numbers. The caller
38
- * (builder/core.ts) is responsible for reading the correct axis from
39
- * the config and from ResizeObserver entries (blockSize vs inlineSize).
40
- *
41
- * Internally maintains a Map of measured sizes keyed by item index.
42
- * Unmeasured items fall back to the estimated size. The underlying
43
- * prefix-sum array is rebuilt when measurements change.
44
- *
45
- * The size function fed into the variable SizeCache becomes:
46
- * (index) => measuredSizes.has(index) ? measuredSizes.get(index) : estimatedSize
47
- *
48
- * This means all existing viewport, compression, and range calculations
49
- * work unchanged — they only see a SizeCache with variable sizes.
50
- */
51
- export declare const createMeasuredSizeCache: (estimatedSize: number, initialTotal: number) => MeasuredSizeCache;
52
- //# sourceMappingURL=measured.d.ts.map
@@ -1,113 +0,0 @@
1
- /**
2
- * vlist - DOM Rendering
3
- * Efficient DOM rendering with element pooling
4
- * Supports compression for large lists (1M+ items)
5
- */
6
- import type { VListItem, ItemTemplate, Range } from "../types";
7
- import type { CompressionState } from "./viewport";
8
- import type { SizeCache } from "./sizes";
9
- /**
10
- * Optional compression position calculator.
11
- * Injected by the monolithic factory or the withCompression feature.
12
- * When not provided, the renderer uses simple sizeCache offsets.
13
- */
14
- export type CompressedPositionFn = (index: number, scrollTop: number, sizeCache: SizeCache, totalItems: number, containerHeight: number, compression: CompressionState, rangeStart?: number) => number;
15
- /**
16
- * Optional compression state getter.
17
- * Injected by the monolithic factory or the withCompression feature.
18
- * When not provided, the renderer assumes no compression.
19
- */
20
- export type CompressionStateFn = (totalItems: number, sizeCache: SizeCache) => CompressionState;
21
- /** Element pool for recycling DOM elements */
22
- export interface ElementPool {
23
- /** Get an element from the pool (or create new) */
24
- acquire: () => HTMLElement;
25
- /** Return an element to the pool */
26
- release: (element: HTMLElement) => void;
27
- /** Clear the pool */
28
- clear: () => void;
29
- /** Get pool statistics */
30
- stats: () => {
31
- poolSize: number;
32
- created: number;
33
- reused: number;
34
- };
35
- }
36
- /** Compression context for positioning */
37
- export interface CompressionContext {
38
- scrollPosition: number;
39
- totalItems: number;
40
- containerSize: number;
41
- rangeStart: number;
42
- /** Pre-computed compression state (includes force flag) */
43
- compression?: CompressionState;
44
- }
45
- /** DOM structure created by createDOMStructure */
46
- export interface DOMStructure {
47
- root: HTMLElement;
48
- viewport: HTMLElement;
49
- content: HTMLElement;
50
- items: HTMLElement;
51
- /** Visually-hidden live region for screen reader announcements */
52
- liveRegion: HTMLElement;
53
- }
54
- /** Renderer instance */
55
- export interface Renderer<T extends VListItem = VListItem> {
56
- /** Render items for a range */
57
- render: (items: T[], range: Range, selectedIds: Set<string | number>, focusedIndex: number, compressionCtx?: CompressionContext) => void;
58
- /** Update item positions (for compressed scrolling) */
59
- updatePositions: (compressionCtx: CompressionContext) => void;
60
- /** Update a single item */
61
- updateItem: (index: number, item: T, isSelected: boolean, isFocused: boolean) => void;
62
- /** Update only CSS classes on a rendered item (no template re-evaluation) */
63
- updateItemClasses: (index: number, isSelected: boolean, isFocused: boolean) => void;
64
- /** Get rendered item element by index */
65
- getElement: (index: number) => HTMLElement | undefined;
66
- /**
67
- * Reorder DOM children to match logical item order (by data-index).
68
- * Called on scroll idle so screen readers encounter items in the correct
69
- * sequence. Items are position:absolute so visual layout is unaffected.
70
- */
71
- sortDOM: () => void;
72
- /** Clear all rendered items */
73
- clear: () => void;
74
- /** Destroy renderer and cleanup */
75
- destroy: () => void;
76
- }
77
- /**
78
- * Create an element pool for recycling DOM elements
79
- * Reduces garbage collection and improves performance
80
- */
81
- export declare const createElementPool: (tagName?: string, maxSize?: number) => ElementPool;
82
- /**
83
- * Create a renderer for managing DOM elements
84
- * Supports compression for large lists
85
- */
86
- export declare const createRenderer: <T extends VListItem = VListItem>(itemsContainer: HTMLElement, template: ItemTemplate<T>, sizeCache: SizeCache, classPrefix: string, totalItemsGetter?: () => number, ariaIdPrefix?: string, isX?: boolean, crossAxisSize?: number, compressionFns?: {
87
- getState: CompressionStateFn;
88
- getPosition: CompressedPositionFn;
89
- }, striped?: boolean | "data" | "even" | "odd", stripeIndexFn?: () => (index: number) => number, ariaPosInSetGetter?: (layoutIndex: number) => number, interactive?: boolean) => Renderer<T>;
90
- /**
91
- * Create the vlist DOM structure
92
- */
93
- export declare const createDOMStructure: (container: HTMLElement, classPrefix: string, ariaLabel?: string, isX?: boolean, interactive?: boolean) => DOMStructure;
94
- /**
95
- * Update content height for virtual scrolling
96
- */
97
- export declare const updateContentHeight: (content: HTMLElement, totalHeight: number) => void;
98
- /**
99
- * Update content width for horizontal virtual scrolling
100
- */
101
- export declare const updateContentWidth: (content: HTMLElement, totalWidth: number) => void;
102
- /**
103
- * Get container dimensions
104
- */
105
- export declare const getContainerDimensions: (viewport: HTMLElement) => {
106
- width: number;
107
- height: number;
108
- };
109
- /**
110
- * Resolve container from selector or element
111
- */
112
- export declare const resolveContainer: (container: HTMLElement | string) => HTMLElement;
113
- //# sourceMappingURL=renderer.d.ts.map
@@ -1,121 +0,0 @@
1
- /**
2
- * vlist - Compression Module
3
- * Pure functions for handling large lists that exceed browser size limits
4
- *
5
- * When a list's total size (sum of all item sizes) exceeds the browser's
6
- * maximum element size (~16.7M pixels), we "compress" the virtual scroll space.
7
- *
8
- * Key concepts:
9
- * - actualSize: The true size if all items were rendered
10
- * - virtualSize: The capped size used for the scroll container (≤ MAX_VIRTUAL_SIZE)
11
- * - compressionRatio: virtualSize / actualSize (1 = no compression, <1 = compressed)
12
- *
13
- * When compressed:
14
- * - Scroll position maps to item index via ratio, not pixel math
15
- * - Item positions are calculated relative to a "virtual index" at current scroll
16
- * - Near-bottom interpolation ensures the last items are reachable
17
- */
18
- import type { Range } from "../types";
19
- import { MAX_VIRTUAL_SIZE } from "../constants";
20
- import type { SizeCache } from "./sizes";
21
- export { MAX_VIRTUAL_SIZE };
22
- /** Compression calculation result */
23
- export interface CompressionState {
24
- /** Whether compression is active */
25
- isCompressed: boolean;
26
- /** The actual total size (uncompressed) */
27
- actualSize: number;
28
- /** The virtual size (capped at MAX_VIRTUAL_SIZE) */
29
- virtualSize: number;
30
- /** Compression ratio (1 = no compression, <1 = compressed) */
31
- ratio: number;
32
- }
33
- /**
34
- * Calculate compression state for a list
35
- * Pure function - no side effects
36
- *
37
- * @param _totalItems - Total number of items
38
- * @param sizeCache - Size cache for item sizes/offsets
39
- * @param force - When true, enables compressed mode even if total size is under the limit.
40
- * Useful for testing, consistent UX, or preemptively enabling compression
41
- * before the list grows past the browser limit.
42
- */
43
- export declare const getCompressionState: (_totalItems: number, sizeCache: SizeCache, force?: boolean) => CompressionState;
44
- /**
45
- * Calculate visible range with compression support
46
- * Pure function - no side effects
47
- *
48
- * @param scrollTop - Current scroll position
49
- * @param containerHeight - Viewport container height
50
- * @param sizeCache - Size cache for item sizes/offsets
51
- * @param totalItems - Total number of items
52
- * @param compression - Compression state
53
- * @param out - Output range to mutate (avoids allocation on hot path)
54
- */
55
- export declare const calculateCompressedVisibleRange: (scrollPosition: number, containerHeight: number, sizeCache: SizeCache, totalItems: number, compression: CompressionState, out: Range) => Range;
56
- /**
57
- * Calculate render range with compression support (adds overscan)
58
- * Pure function - no side effects
59
- *
60
- * @param out - Output range to mutate (avoids allocation on hot path)
61
- */
62
- export declare const calculateCompressedRenderRange: (visibleRange: Range, overscan: number, totalItems: number, out: Range) => Range;
63
- /**
64
- * Calculate item position (translateY) with compression support
65
- * Pure function - no side effects
66
- *
67
- * In compressed mode (manual wheel scrolling, overflow: hidden), items are
68
- * positioned RELATIVE TO THE VIEWPORT. The scroll container doesn't actually
69
- * scroll - we intercept wheel events and manually position items.
70
- *
71
- * Key insight:
72
- * - Calculate a "virtual scroll index" from the scroll ratio
73
- * - Items are positioned relative to this virtual index using actual heights
74
- * - Each item keeps its full height for proper rendering
75
- *
76
- * @param index - Item index
77
- * @param scrollTop - Current (virtual) scroll position
78
- * @param sizeCache - Size cache for item sizes/offsets
79
- * @param totalItems - Total number of items
80
- * @param containerHeight - Viewport container height
81
- * @param compression - Compression state
82
- */
83
- export declare const calculateCompressedItemPosition: (index: number, scrollPosition: number, sizeCache: SizeCache, totalItems: number, _containerHeight: number, compression: CompressionState, _rangeStart?: number) => number;
84
- /**
85
- * Calculate scroll position to bring an index into view (with compression)
86
- * Pure function - no side effects
87
- *
88
- * @param index - Target item index
89
- * @param sizeCache - Size cache for item sizes/offsets
90
- * @param containerHeight - Viewport container height
91
- * @param totalItems - Total number of items
92
- * @param compression - Compression state
93
- * @param align - Alignment within viewport
94
- */
95
- export declare const calculateCompressedScrollToIndex: (index: number, sizeCache: SizeCache, containerHeight: number, totalItems: number, compression: CompressionState, align?: "start" | "center" | "end") => number;
96
- /**
97
- * Calculate the approximate item index at a given scroll position
98
- * Useful for debugging and scroll position restoration
99
- * Pure function - no side effects
100
- */
101
- export declare const calculateIndexFromScrollPosition: (scrollPosition: number, sizeCache: SizeCache, totalItems: number, compression: CompressionState) => number;
102
- /**
103
- * Check if compression is needed for a list configuration
104
- * Pure function - no side effects
105
- *
106
- * Note: This overload accepts a HeightCache for variable heights.
107
- * For simple fixed-height checks, use needsCompressionFixed().
108
- */
109
- export declare const needsCompression: (totalItems: number, heightOrCache: number | SizeCache) => boolean;
110
- /**
111
- * Calculate maximum items supported without compression
112
- * Only meaningful for fixed-height items
113
- * Pure function - no side effects
114
- */
115
- export declare const getMaxItemsWithoutCompression: (itemSize: number) => number;
116
- /**
117
- * Get human-readable compression info for debugging
118
- * Pure function - no side effects
119
- */
120
- export declare const getCompressionInfo: (totalItems: number, sizeCache: SizeCache, force?: boolean) => string;
121
- //# sourceMappingURL=scale.d.ts.map
@@ -1,23 +0,0 @@
1
- /**
2
- * vlist - Smart Edge Scroll
3
- * Shared scroll utility used by both core baseline and withSelection feature.
4
- * Only scrolls when the target item is outside the viewport; aligns to nearest edge.
5
- *
6
- * Split into two functions for tree-shaking:
7
- * - scrollToFocusSimple: normal mode only (used by base builder)
8
- * - scrollToFocus: handles both normal and compressed modes (used by features)
9
- */
10
- import type { SizeCache } from "./sizes";
11
- import type { CompressionState } from "./scale";
12
- import type { Range } from "../types";
13
- /**
14
- * Simple scroll-to-focus: normal (non-compressed) mode only.
15
- * Padding-aware: accounts for CSS padding on the content element.
16
- */
17
- export declare const scrollToFocusSimple: (index: number, sizeCache: SizeCache, scrollPosition: number, containerSize: number, startPadding?: number, endPadding?: number) => number;
18
- /**
19
- * Full scroll-to-focus: handles both normal and compressed (withScale) modes.
20
- * Used by withSelection feature which must work with compression.
21
- */
22
- export declare const scrollToFocus: (index: number, sizeCache: SizeCache, scrollPosition: number, containerSize: number, startPadding?: number, endPadding?: number, compression?: CompressionState | null, totalItems?: number, visibleRange?: Range | null) => number;
23
- //# sourceMappingURL=scroll.d.ts.map
@@ -1,139 +0,0 @@
1
- /**
2
- * vlist - Virtual Scrolling Core
3
- * Pure functions for virtual scroll calculations
4
- *
5
- * Compression support is NOT imported here — it's injected via
6
- * CompressionState parameters. When compression is inactive
7
- * (the common case), all calculations use simple size-cache math
8
- * with zero dependency on the compression module.
9
- *
10
- * This keeps the builder core lightweight. The withCompression feature
11
- * and the monolithic createVList entry point import compression
12
- * separately and pass the state in.
13
- */
14
- import type { Range, ViewportState } from "../types";
15
- import type { SizeCache } from "./sizes";
16
- /** Compression calculation result */
17
- export interface CompressionState {
18
- /** Whether compression is active */
19
- isCompressed: boolean;
20
- /** The actual total size (uncompressed) */
21
- actualSize: number;
22
- /** The virtual size (capped at MAX_VIRTUAL_SIZE) */
23
- virtualSize: number;
24
- /** Compression ratio (1 = no compression, <1 = compressed) */
25
- ratio: number;
26
- }
27
- /**
28
- * A "no compression" state for lists that don't need it.
29
- * Used by the builder core when withCompression is not installed.
30
- */
31
- export declare const NO_COMPRESSION: CompressionState;
32
- /**
33
- * Create a trivial compression state from a size cache.
34
- * No compression logic — just reads the total height.
35
- * For use when the full compression module is not loaded.
36
- */
37
- export declare const getSimpleCompressionState: (_totalItems: number, sizeCache: SizeCache) => CompressionState;
38
- /**
39
- * Signature for the function that calculates the visible item range.
40
- * The compression module provides a version that handles compressed scroll;
41
- * virtual.ts provides a simple fallback for non-compressed lists.
42
- */
43
- export type VisibleRangeFn = (scrollPosition: number, containerHeight: number, sizeCache: SizeCache, totalItems: number, compression: CompressionState, out: Range) => Range;
44
- /**
45
- * Signature for the scroll-to-index calculator.
46
- */
47
- export type ScrollToIndexFn = (index: number, sizeCache: SizeCache, containerHeight: number, totalItems: number, compression: CompressionState, align: "start" | "center" | "end") => number;
48
- /**
49
- * Calculate visible range using size cache lookups.
50
- * Fast path for lists that don't need compression (< ~350 000 items at 48px).
51
- * Mutates `out` to avoid allocation on the scroll hot path.
52
- */
53
- export declare const simpleVisibleRange: VisibleRangeFn;
54
- /**
55
- * Calculate render range (adds overscan around visible range).
56
- * This function is compression-agnostic — works for both paths.
57
- * Mutates `out` to avoid allocation on the scroll hot path.
58
- */
59
- export declare const calculateRenderRange: (visibleRange: Range, overscan: number, totalItems: number, out: Range) => Range;
60
- /**
61
- * Simple scroll-to-index calculation (non-compressed).
62
- * Uses size cache offsets directly.
63
- */
64
- export declare const simpleScrollToIndex: ScrollToIndexFn;
65
- /**
66
- * Calculate total content height.
67
- * Uses compression's virtualSize when compressed, raw height otherwise.
68
- */
69
- export declare const calculateTotalSize: (_totalItems: number, sizeCache: SizeCache, compression?: CompressionState | null) => number;
70
- /**
71
- * Calculate actual total size (without compression cap)
72
- */
73
- export declare const calculateActualSize: (_totalItems: number, sizeCache: SizeCache) => number;
74
- /**
75
- * Calculate the offset (translateY) for an item
76
- * For non-compressed lists only
77
- */
78
- export declare const calculateItemOffset: (index: number, sizeCache: SizeCache) => number;
79
- /**
80
- * Clamp scroll position to valid range
81
- */
82
- export declare const clampScrollPosition: (scrollPosition: number, totalHeight: number, containerHeight: number) => number;
83
- /**
84
- * Determine scroll direction
85
- */
86
- export declare const getScrollDirection: (currentScrollTop: number, previousScrollTop: number, isX?: boolean) => "up" | "down" | "left" | "right";
87
- /**
88
- * Create initial viewport state.
89
- *
90
- * Accepts an optional `visibleRangeFn` so that compression-aware callers
91
- * can inject the compressed version. Defaults to `simpleVisibleRange`.
92
- */
93
- export declare const createViewportState: (containerHeight: number, sizeCache: SizeCache, totalItems: number, overscan: number, compression: CompressionState, visibleRangeFn?: VisibleRangeFn) => ViewportState;
94
- /**
95
- * Update viewport state after scroll.
96
- * Mutates state in place for performance on the scroll hot path.
97
- */
98
- export declare const updateViewportState: (state: ViewportState, scrollPosition: number, sizeCache: SizeCache, totalItems: number, overscan: number, compression: CompressionState, visibleRangeFn?: VisibleRangeFn) => ViewportState;
99
- /**
100
- * Update viewport state when container resizes.
101
- * Mutates state in place for performance.
102
- */
103
- export declare const updateViewportSize: (state: ViewportState, containerHeight: number, sizeCache: SizeCache, totalItems: number, overscan: number, compression: CompressionState, visibleRangeFn?: VisibleRangeFn) => ViewportState;
104
- /**
105
- * Update viewport state when total items changes.
106
- * Mutates state in place for performance.
107
- */
108
- export declare const updateViewportItems: (state: ViewportState, sizeCache: SizeCache, totalItems: number, overscan: number, compression: CompressionState, visibleRangeFn?: VisibleRangeFn) => ViewportState;
109
- /**
110
- * Calculate scroll position to bring an index into view.
111
- *
112
- * Accepts an optional `scrollToIndexFn` so that compression-aware callers
113
- * can inject the compressed version. Defaults to `simpleScrollToIndex`.
114
- */
115
- export declare const calculateScrollToIndex: (index: number, sizeCache: SizeCache, containerHeight: number, totalItems: number, align: "start" | "center" | "end" | undefined, compression: CompressionState, scrollToIndexFn?: ScrollToIndexFn) => number;
116
- /**
117
- * Check if two ranges are equal
118
- */
119
- export declare const rangesEqual: (a: Range, b: Range) => boolean;
120
- /**
121
- * Check if an index is within a range
122
- */
123
- export declare const isInRange: (index: number, range: Range) => boolean;
124
- /**
125
- * Get the count of items in a range
126
- */
127
- export declare const getRangeCount: (range: Range) => number;
128
- /**
129
- * Create an array of indices from a range
130
- */
131
- export declare const rangeToIndices: (range: Range) => number[];
132
- /**
133
- * Calculate which indices need to be added/removed when range changes
134
- */
135
- export declare const diffRanges: (oldRange: Range, newRange: Range) => {
136
- add: number[];
137
- remove: number[];
138
- };
139
- //# sourceMappingURL=viewport.d.ts.map