diff --git a/.gitignore b/.gitignore index e398c85..0189bc5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ !.env.example *.log .eslintcache -vite.config.js.timestamp-* \ No newline at end of file +vite.config.js.timestamp-* +.idea diff --git a/src/lib/SizeAndPositionManager.ts b/src/lib/SizeAndPositionManager.ts index 8e1435d..e31cb07 100644 --- a/src/lib/SizeAndPositionManager.ts +++ b/src/lib/SizeAndPositionManager.ts @@ -60,13 +60,13 @@ export default class SizeAndPositionManager { } } - checkForMismatchItemSizeAndItemCount() { + private checkForMismatchItemSizeAndItemCount() { if (Array.isArray(this.itemSize) && this.itemSize.length < this.modelCount) { throw Error(`When itemSize is an array, itemSize.length can't be smaller than itemCount`); } } - getSize(index: number) { + private getSize(index: number) { const { itemSize } = this; if (typeof itemSize === 'function') { @@ -96,9 +96,6 @@ export default class SizeAndPositionManager { this.totalSize = totalSize; } - getLastMeasuredIndex() { - return this.lastMeasuredIndex; - } /** * This method returns the size and position for the item at the specified index. @@ -118,7 +115,7 @@ export default class SizeAndPositionManager { * This is used when itemSize is a function. * just-in-time calculates (or used cached values) for items leading up to the index. */ - getJustInTimeSizeAndPositionForIndex(index: number) { + private getJustInTimeSizeAndPositionForIndex(index: number) { if (index > this.lastMeasuredIndex) { const lastMeasuredSizeAndPosition = this.getSizeAndPositionOfLastMeasuredItem(); let offset = lastMeasuredSizeAndPosition.offset + lastMeasuredSizeAndPosition.size; @@ -144,13 +141,13 @@ export default class SizeAndPositionManager { return this.itemSizeAndPositionData[index]; } - getSizeAndPositionOfLastMeasuredItem() { + private getSizeAndPositionOfLastMeasuredItem() { return this.lastMeasuredIndex >= 0 ? this.itemSizeAndPositionData[this.lastMeasuredIndex] : { offset: 0, size: 0 }; } - getEstimatedItemSize(): number { + private getEstimatedItemSize(): number { return this.estimatedItemSize || (typeof this.itemSize === 'number' && this.itemSize) || 50; } @@ -273,7 +270,7 @@ export default class SizeAndPositionManager { * This allows partially visible items (with offsets just before/above the fold) to be visible. * */ - findNearestItem(offset: number): number { + private findNearestItem(offset: number): number { if (isNaN(offset)) { throw Error(`Invalid offset ${offset} specified`); } diff --git a/src/lib/VirtualList.svelte b/src/lib/VirtualList.svelte index c70bc3d..45305a5 100644 --- a/src/lib/VirtualList.svelte +++ b/src/lib/VirtualList.svelte @@ -71,7 +71,7 @@ onVisibleRangeUpdate, onAfterScroll, - // dom + // css class: className = '', style = '', diff --git a/src/routes/examples/positioning2/code.svelte b/src/routes/examples/positioning2/code.svelte index 54d5e23..b3b8eac 100644 --- a/src/routes/examples/positioning2/code.svelte +++ b/src/routes/examples/positioning2/code.svelte @@ -125,7 +125,7 @@ {scrollToAlignment} {scrollToBehaviour} onVisibleRangeUpdate={handleMessage}> - {#snippet slot({ item: _item, style, index }: VirtualListModel)} + {#snippet slot({ item: _item, style, index })}
Item #{index}