Created
January 24, 2025 16:25
-
-
Save abteilung/3fd6903589c88f637bf252226a7e1d4d to your computer and use it in GitHub Desktop.
Sveltekit execute Item transitions when navigating
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script lang="ts"> | |
// These lines let the page transition animations come alive! | |
import { onNavigate } from '$app/navigation'; | |
onNavigate((navigation) => { | |
if (!document.startViewTransition) return; | |
return new Promise<void>((resolve) => { | |
document.startViewTransition(async () => { | |
resolve(); | |
await navigation.complete; | |
}); | |
}); | |
}); | |
let { | |
children, | |
data = { | |
stuffs: [], | |
} | |
} = $props(); | |
let { stuffs = [] } = $derived(data); | |
</script> | |
{@render children?.()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment