Created
March 15, 2021 22:46
-
-
Save tohagan/63b4002072156bc308830755acc99651 to your computer and use it in GitHub Desktop.
Vue: Compute slide transition on route change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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