Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
import { List } from "https://unpkg.com/svelte-virtual@next/dist/index.js";

const itemSize = 20;

let currentIndex = $state(0)
let height = $state(500);
let items = [...Array(10000).keys()];
let grid = $state();
let scrollPosition = $state(0);
let scrollAlignment = $state("auto");
let scrollBehavior = $state("auto");
let usePlaceholder = $state(false);

const getRandomIndex = () => ~~(Math.random() * items.length);
</script>

<div>
<div>
<label for="listHeight">list height</label>
<input id="listHeight" type="number" bind:value={height} />
</div>
<div>
<label for="scrollAlignment">scroll alignment</label>
<select id="scrollAlignment" bind:value={scrollAlignment}>
<option value="auto">auto</option>
<option value="start">start</option>
<option value="center">center</option>
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */