Skip to content

Animate on Vue Router Exit #28

Answered by milesingrams
zachkrall asked this question in Q&A
Discussion options

You must be logged in to vote

I would see if wrapping the <router-view></router-view> component with a transition would work. aka:

<XyzTransition appear mode="out-in" xyz="fade duration-10">
  <router-view></router-view>
</XyzTransition>

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 the XyzTransition component.

Similarly to how you would use the native Vue transi…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by mattaningram
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@milesingrams
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants