Replies: 2 comments
-
I guess I've solved my own issue like this: (IDK why but delay makes it work) import React, { useEffect } from 'react';
import { router } from '@inertiajs/react';
export default function DefaultLayout({ children }: { children: React.ReactNode }) {
useEffect(() => {
if (!document.startViewTransition) return;
// When a navigation is triggered...
const handleNavigate = (e: CustomEvent) => {
// Skip non-GET requests.
if (e.detail.visit.method !== 'get') return;
// Start the view transition.
document.startViewTransition(async () => {
await new Promise<void>((resolve) => {
// Complete the transition
const offFinish = router.on('finish', () => {
// Delay is required
setTimeout(() => {
offFinish();
resolve();
}, 10);
});
});
});
};
// Listen for Inertia navigation events.
const offNavigate = router.on('before', handleNavigate);
// Cleanup on unmount.
return () => {
offNavigate();
};
}, []);
return <>{children}</>;
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Not really good, causes slight freeze when submitting a form (using post) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am talking about: https://developer.mozilla.org/en-US/docs/Web/API/View_Transition_API
In SvelteKit it was done like this: https://svelte.dev/blog/view-transitions#Getting-started-with-view-transitions
So I tried doing the same:
It works when navigating from one page to another ... However it doesn't work when I use
viewTransitionName
on a single unique component that exists in both pages.Any ideas how to get it to work?
Beta Was this translation helpful? Give feedback.
All reactions