✨ 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
|
||||
|
||||
onMount(async () => {
|
||||
// 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)
|
||||
}
|
||||
})
|
||||
$: doNotScroll = !$page.url.searchParams.get('country') && !$page.url.pathname.includes('/shop')
|
||||
</script>
|
||||
|
||||
|
||||
<main class={name}
|
||||
in:fade={{ duration: DURATION.PAGE_IN, delay: DURATION.PAGE_DELAY }}
|
||||
out:fade={{ duration: DURATION.PAGE_OUT }}
|
||||
on:outroend={() => doNotScroll && scrollToTop()}
|
||||
>
|
||||
<slot />
|
||||
</main>
|
||||
Reference in New Issue
Block a user