Skip to content

Commit 2c41030

Browse files
move event listener to svelte window
1 parent a39cbe2 commit 2c41030

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/components/blog/table-of-contents.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
1010
let isScrolled: boolean = false;
1111
12-
window.addEventListener('scroll', () => {
12+
const handleIsScrolled = () => {
1313
isScrolled = !!window.scrollY;
14-
});
14+
};
1515
1616
export let toc: Array<TocItem> = [];
1717
export let heading: string = 'Table of Contents';
1818
</script>
1919

20+
<svelte:window on:scroll={handleIsScrolled} />
21+
2022
<nav class="sticky top-32 col-span-3 mt-2 -ml-4 hidden h-[800px] flex-col gap-6 lg:flex">
2123
<span class="text-micro tracking-loose text-primary font-aeonik-fono ps-6 uppercase"
2224
>{heading}</span

0 commit comments

Comments
 (0)