Animate on Vue Router Exit #28
-
Hi 👋 I was wondering if anyone might have ideas on how to best allow animxyz exit transitions to happen before routes change similar to Framer Motion's exitBeforeEnter. Right now, I'm manually toggling a "visible" value inside of <XyzTransition appear xyz="fade down stagger" duration="auto">
<div v-if="visible">
<!-- content -->
</div>
</XyzTransition> beforeRouteLeave(to, from, next) {
this.visible = false;
setTimeout(() => next(), 550);
} I'm wondering if there might be better solutions out there. Thanks 😄 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I would see if wrapping the <XyzTransition appear mode="out-in" xyz="fade duration-10">
<router-view></router-view>
</XyzTransition> Here is an edited version of your codesandbox: If you want just the children to animate and not the root div of the route components you can add the class Additionally, if you want each page to have a different transition you can add a different Similarly to how you would use the native Vue transition component with Vue router. https://router.vuejs.org/guide/advanced/transitions.html |
Beta Was this translation helpful? Give feedback.
-
Also, thanks for using the new discussions board!! |
Beta Was this translation helpful? Give feedback.
-
@milesingrams thanks! that seems to work perfectly! |
Beta Was this translation helpful? Give feedback.
I would see if wrapping the
<router-view></router-view>
component with a transition would work. aka:Here is an edited version of your codesandbox:
https://codesandbox.io/s/animxyz-vue-router-transitions-forked-k9ci8?file=/src/App.vue
If you want just the children to animate and not the root div of the route components you can add the class
xyz-none
to the root div.Additionally, if you want each page to have a different transition you can add a different
xyz="..."
property on the root div instead of on theXyzTransition
component.Similarly to how you would use the native Vue transi…