Skip to content

Instantly share code, notes, and snippets.

@tohagan
Created March 15, 2021 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tohagan/63b4002072156bc308830755acc99651 to your computer and use it in GitHub Desktop.
Save tohagan/63b4002072156bc308830755acc99651 to your computer and use it in GitHub Desktop.
Vue: Compute slide transition on route change
// then, in the parent component,
// watch the `$route` to determine the transition to use
watch: {
'$route' (to, from) {
const toDepth = to.path.split('/').length
const fromDepth = from.path.split('/').length
this.transitionName = toDepth < fromDepth ? 'slide-right' : 'slide-left'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment