Debug Mode
Debug mode provides detailed information about the virtual list’s internal state, useful for development and troubleshooting.
Debug Output
Scroll to see debug info...
Enabling Debug Mode
Via Props
<VirtualList {items} debug={true}>
{#snippet renderItem(item)}
<div>{item.text}</div>
{/snippet}
</VirtualList><VirtualList {items} debug={true}>
{#snippet renderItem(item)}
<div>{item.text}</div>
{/snippet}
</VirtualList>Via Environment Variable
PUBLIC_SVELTE_VIRTUAL_LIST_DEBUG=truePUBLIC_SVELTE_VIRTUAL_LIST_DEBUG=trueDebug Information
When enabled, the component provides:
| Property | Description |
|---|---|
startIndex | First rendered item index |
endIndex | Last rendered item index |
totalItems | Total items in the list |
visibleItemsCount | Number of items currently visible |
processedItems | Items with measured heights |
averageItemHeight | Calculated average height |
atTop | Whether scrolled to top |
atBottom | Whether scrolled to bottom |
totalHeight | Total calculated content height |
Custom Debug Handler
Capture debug info programmatically:
<script lang="ts">
import VirtualList from '@humanspeak/svelte-virtual-list'
import type { SvelteVirtualListDebugInfo } from '@humanspeak/svelte-virtual-list'
function handleDebug(info: SvelteVirtualListDebugInfo) {
console.log('Visible range:', info.startIndex, '-', info.endIndex)
console.log('Average height:', info.averageItemHeight)
}
</script>
<VirtualList
{items}
debug={true}
debugFunction={handleDebug}
>
{#snippet renderItem(item)}
<div>{item.text}</div>
{/snippet}
</VirtualList><script lang="ts">
import VirtualList from '@humanspeak/svelte-virtual-list'
import type { SvelteVirtualListDebugInfo } from '@humanspeak/svelte-virtual-list'
function handleDebug(info: SvelteVirtualListDebugInfo) {
console.log('Visible range:', info.startIndex, '-', info.endIndex)
console.log('Average height:', info.averageItemHeight)
}
</script>
<VirtualList
{items}
debug={true}
debugFunction={handleDebug}
>
{#snippet renderItem(item)}
<div>{item.text}</div>
{/snippet}
</VirtualList>Visual Overlay
When debug={true}, a visual overlay displays real-time stats in the corner of the viewport.