✨ Scroll back to top when transition out is finished
Potentially the end of nightmares for page transitions with `sveltekit:noscroll`?
This commit is contained in:
@@ -7,22 +7,14 @@
|
|||||||
|
|
||||||
export let name: string
|
export let name: string
|
||||||
|
|
||||||
onMount(async () => {
|
$: doNotScroll = !$page.url.searchParams.get('country') && !$page.url.pathname.includes('/shop')
|
||||||
// Disable when changing filters on /photos and shop?
|
|
||||||
if (!$page.url.searchParams.get('country') && !$page.url.pathname.includes('/shop')) {
|
|
||||||
await tick()
|
|
||||||
setTimeout(() => {
|
|
||||||
// Scroll back to top between page transitions
|
|
||||||
scrollToTop()
|
|
||||||
}, DURATION.PAGE_DELAY)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<main class={name}
|
<main class={name}
|
||||||
in:fade={{ duration: DURATION.PAGE_IN, delay: DURATION.PAGE_DELAY }}
|
in:fade={{ duration: DURATION.PAGE_IN, delay: DURATION.PAGE_DELAY }}
|
||||||
out:fade={{ duration: DURATION.PAGE_OUT }}
|
out:fade={{ duration: DURATION.PAGE_OUT }}
|
||||||
|
on:outroend={() => doNotScroll && scrollToTop()}
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</main>
|
</main>
|
||||||
Reference in New Issue
Block a user