Skip to content

Instantly share code, notes, and snippets.

@abteilung
Created January 24, 2025 16:25
Show Gist options
  • Save abteilung/3fd6903589c88f637bf252226a7e1d4d to your computer and use it in GitHub Desktop.
Save abteilung/3fd6903589c88f637bf252226a7e1d4d to your computer and use it in GitHub Desktop.
Sveltekit execute Item transitions when navigating
<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