diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index d303a95..210311b 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -6,18 +6,82 @@
import "../style/material.scss"
import '@unocss/reset/normalize.css'
import '@unocss/reset/tailwind-v4.css'
+ import type { LayoutProps } from "./$types"
+ import { onNavigate } from '$app/navigation'
- import AppBar from "../components/appbar/AppBar.svelte"
- import type { LayoutProps } from "./$types";
+ let { data, children }: LayoutProps = $props()
- let { data, children }: LayoutProps = $props();
-
+ // This function is called when the user navigates to a new page, it will start the view transition
+ onNavigate((navigation) => {
+ if (!document.startViewTransition) return
+
+ const direction = navigation.delta && navigation.delta < 0 ? 'back' : 'forward'
+ console.log(direction)
+ document.documentElement.dataset.transitionDirection = direction
+
+ return new Promise((resolve) => {
+ document.startViewTransition(async () => {
+ resolve()
+ await navigation.complete
+ })
+ })
+ })