In svelte 5, I want to store window.scrollY
before the component unmounts to be able to restore it later.
I tried console logging window.scrollY
inside onDestroy
, the cleanup functions of onMount
and $effect()
, all of them just gave 0
. In React's useLayoutEffect
cleanup function you get the correct window.scrollY
.
Is there any similar alternative to useLayoutEffect
cleanup function in Svelte 5?
I know than we can solve this using event listeners but I just want to do it with effects.