Window Scroll

Reactive window scroll.

Usage

<script>
    import { windowScroll } from "@sveu/browser"

    const { x, y } = windowScroll()

</script>
<script>
    import { windowScroll } from "@sveu/browser"

    const { x, y } = windowScroll()

</script>
svelte

Example

x: 0
y: 0
<script>
    import { windowScroll } from "@sveu/browser"

    const { x, y } = windowScroll()
</script>

<div class="flex flex-col h-screen w-full items-center justify-center">
    x: {$x}<br />
    y: {$y}
</div>
<script>
    import { windowScroll } from "@sveu/browser"

    const { x, y } = windowScroll()
</script>

<div class="flex flex-col h-screen w-full items-center justify-center">
    x: {$x}<br />
    y: {$y}
</div>
svelte
1
2
3
4
5
6
7
8
9
10
Click fold/expand code

API

Returns

Name Description Type
x A readable store with the x position Readable<number>
y A readable store with the y position Readable<number>