How do I add page transitions with Inertia and vue? #810
Unanswered
ApolloDevs
asked this question in
Help (Vue)
Replies: 2 comments 4 replies
-
@ApolloDevs Try to wrap your slot with a Vue transition, e.g. <transition name="fade" mode="out-in" appear>
<slot />
</transition> CSS for Vue 3 .fade-enter-active,
.fade-leave-active {
@apply transition-opacity;
}
.fade-enter-from,
.fade-leave-to {
@apply opacity-0;
} |
Beta Was this translation helpful? Give feedback.
4 replies
-
Finally I found what I was looking for: https://hjb.dev/posts/using-the-view-transitions-api-with-inertia-6 <script setup>
import { onUnmounted } from "vue";
if (document.startViewTransition) {
function handleInertiaStart() {
document.startViewTransition(async () => {
return new Promise((resolve) => {
document.addEventListener(
"inertia:finish",
() => {
resolve();
},
{once: true},
);
});
});
}
document.addEventListener("inertia:start", handleInertiaStart);
onUnmounted(() => {
document.removeEventListener("inertia:start", handleInertiaStart);
});
}
</script> |
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
-
I have attempted a few examples that I have found online but sadly I haven't really got anywhere. I'm using the Laravel adapter with InertiaJS and Vue and TailwindCSS.
Say I have the following layout -
How would I make the items inside the slot transition when selecting a new page from the sidebar? I've tried the class with CSS in a <style> tag in the component but no transitions take place. (with wrapped around the slot!) Looking for a basic example to get me off the ground!
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions