You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/window-binding-scroll-store/main.svelte

15 lines
316 B

<script>
import { writable, derived } from 'svelte/store';
const y = writable(0);
const y_squared = derived(y, $y => $y * $y);
</script>
<svelte:window bind:scrollY={$y}/>
<p style="position: fixed; top: 1em; left: 1em;">
scroll y is {$y}. {$y} * {$y} = {$y_squared}
</p>
<div style="height: 9999px">
</div>