@humanspeak/svelte-virtual-list 0.2.6-beta.4 → 0.2.6-beta.5
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/types.d.ts
CHANGED
|
@@ -72,7 +72,11 @@ export type SvelteVirtualListProps = {
|
|
|
72
72
|
* @property {number} startIndex - Index of the first rendered item in the viewport.
|
|
73
73
|
* @property {number} totalItems - Total number of items in the list.
|
|
74
74
|
* @property {number} visibleItemsCount - Number of items currently visible in the viewport.
|
|
75
|
-
* @property {number} processedItems - Number of items
|
|
75
|
+
* @property {number} processedItems - Number of items with measured heights in cache.
|
|
76
|
+
* @property {number} averageItemHeight - Current calculated average height per item.
|
|
77
|
+
* @property {boolean} atTop - Whether the list is scrolled to the top position.
|
|
78
|
+
* @property {boolean} atBottom - Whether the list is scrolled to the bottom position.
|
|
79
|
+
* @property {number} totalHeight - Total calculated height of all items in the list.
|
|
76
80
|
*/
|
|
77
81
|
export type SvelteVirtualListDebugInfo = {
|
|
78
82
|
endIndex: number;
|
|
@@ -81,6 +85,9 @@ export type SvelteVirtualListDebugInfo = {
|
|
|
81
85
|
visibleItemsCount: number;
|
|
82
86
|
processedItems: number;
|
|
83
87
|
averageItemHeight: number;
|
|
88
|
+
atTop: boolean;
|
|
89
|
+
atBottom: boolean;
|
|
90
|
+
totalHeight: number;
|
|
84
91
|
};
|
|
85
92
|
/**
|
|
86
93
|
* Alignment options for programmatic scrolling.
|
|
@@ -41,8 +41,9 @@ export declare function shouldShowDebugInfo(prevRange: {
|
|
|
41
41
|
* This utility function generates a structured debug object that captures the complete
|
|
42
42
|
* state of a virtual list at any given moment. It includes critical metrics such as
|
|
43
43
|
* visible item count, viewport boundaries, total items, processed items with measured
|
|
44
|
-
* heights,
|
|
45
|
-
* monitoring, debugging scroll behavior,
|
|
44
|
+
* heights, height calculations, scroll position, and total content dimensions.
|
|
45
|
+
* This information is essential for performance monitoring, debugging scroll behavior,
|
|
46
|
+
* and optimizing virtual list configurations.
|
|
46
47
|
*
|
|
47
48
|
* Performance considerations:
|
|
48
49
|
* - All calculations are O(1)
|
|
@@ -53,6 +54,8 @@ export declare function shouldShowDebugInfo(prevRange: {
|
|
|
53
54
|
* @param totalItems - Total number of items in the virtual list
|
|
54
55
|
* @param processedItems - Number of items with measured heights (heightCache.length)
|
|
55
56
|
* @param averageItemHeight - Current calculated average height per item in pixels
|
|
57
|
+
* @param scrollTop - Current scroll position in pixels
|
|
58
|
+
* @param viewportHeight - Height of the viewport in pixels
|
|
56
59
|
* @returns {SvelteVirtualListDebugInfo} A structured debug information object
|
|
57
60
|
*
|
|
58
61
|
* @example
|
|
@@ -60,7 +63,9 @@ export declare function shouldShowDebugInfo(prevRange: {
|
|
|
60
63
|
* { start: 0, end: 10 },
|
|
61
64
|
* 1000,
|
|
62
65
|
* 50,
|
|
63
|
-
* 45
|
|
66
|
+
* 45,
|
|
67
|
+
* 200,
|
|
68
|
+
* 400
|
|
64
69
|
* );
|
|
65
70
|
* console.log('Virtual List State:', debugInfo);
|
|
66
71
|
*
|
|
@@ -69,4 +74,4 @@ export declare function shouldShowDebugInfo(prevRange: {
|
|
|
69
74
|
export declare function createDebugInfo(visibleRange: {
|
|
70
75
|
start: number;
|
|
71
76
|
end: number;
|
|
72
|
-
}, totalItems: number, processedItems: number, averageItemHeight: number): SvelteVirtualListDebugInfo;
|
|
77
|
+
}, totalItems: number, processedItems: number, averageItemHeight: number, scrollTop: number, viewportHeight: number): SvelteVirtualListDebugInfo;
|
|
@@ -40,8 +40,9 @@ export function shouldShowDebugInfo(prevRange, currentRange, prevHeight, current
|
|
|
40
40
|
* This utility function generates a structured debug object that captures the complete
|
|
41
41
|
* state of a virtual list at any given moment. It includes critical metrics such as
|
|
42
42
|
* visible item count, viewport boundaries, total items, processed items with measured
|
|
43
|
-
* heights,
|
|
44
|
-
* monitoring, debugging scroll behavior,
|
|
43
|
+
* heights, height calculations, scroll position, and total content dimensions.
|
|
44
|
+
* This information is essential for performance monitoring, debugging scroll behavior,
|
|
45
|
+
* and optimizing virtual list configurations.
|
|
45
46
|
*
|
|
46
47
|
* Performance considerations:
|
|
47
48
|
* - All calculations are O(1)
|
|
@@ -52,6 +53,8 @@ export function shouldShowDebugInfo(prevRange, currentRange, prevHeight, current
|
|
|
52
53
|
* @param totalItems - Total number of items in the virtual list
|
|
53
54
|
* @param processedItems - Number of items with measured heights (heightCache.length)
|
|
54
55
|
* @param averageItemHeight - Current calculated average height per item in pixels
|
|
56
|
+
* @param scrollTop - Current scroll position in pixels
|
|
57
|
+
* @param viewportHeight - Height of the viewport in pixels
|
|
55
58
|
* @returns {SvelteVirtualListDebugInfo} A structured debug information object
|
|
56
59
|
*
|
|
57
60
|
* @example
|
|
@@ -59,19 +62,27 @@ export function shouldShowDebugInfo(prevRange, currentRange, prevHeight, current
|
|
|
59
62
|
* { start: 0, end: 10 },
|
|
60
63
|
* 1000,
|
|
61
64
|
* 50,
|
|
62
|
-
* 45
|
|
65
|
+
* 45,
|
|
66
|
+
* 200,
|
|
67
|
+
* 400
|
|
63
68
|
* );
|
|
64
69
|
* console.log('Virtual List State:', debugInfo);
|
|
65
70
|
*
|
|
66
71
|
* @throws {Error} Will throw if end index is less than start index in visibleRange
|
|
67
72
|
*/
|
|
68
|
-
export function createDebugInfo(visibleRange, totalItems, processedItems, averageItemHeight) {
|
|
73
|
+
export function createDebugInfo(visibleRange, totalItems, processedItems, averageItemHeight, scrollTop, viewportHeight) {
|
|
74
|
+
const totalHeight = totalItems * averageItemHeight;
|
|
75
|
+
const atTop = scrollTop <= 1; // Small tolerance for floating point precision
|
|
76
|
+
const atBottom = scrollTop >= totalHeight - viewportHeight - 1; // Small tolerance
|
|
69
77
|
return {
|
|
70
78
|
visibleItemsCount: visibleRange.end - visibleRange.start,
|
|
71
79
|
startIndex: visibleRange.start,
|
|
72
80
|
endIndex: visibleRange.end,
|
|
73
81
|
totalItems,
|
|
74
82
|
processedItems, // Number of items with measured heights in heightCache
|
|
75
|
-
averageItemHeight
|
|
83
|
+
averageItemHeight,
|
|
84
|
+
atTop,
|
|
85
|
+
atBottom,
|
|
86
|
+
totalHeight
|
|
76
87
|
};
|
|
77
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@humanspeak/svelte-virtual-list",
|
|
3
|
-
"version": "0.2.6-beta.
|
|
3
|
+
"version": "0.2.6-beta.5",
|
|
4
4
|
"description": "A lightweight, high-performance virtual list component for Svelte 5 that renders large datasets with minimal memory usage. Features include dynamic height support, smooth scrolling, TypeScript support, and efficient DOM recycling. Ideal for infinite scrolling lists, data tables, chat interfaces, and any application requiring the rendering of thousands of items without compromising performance. Zero dependencies and fully customizable.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|