Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying different transitions for navigation and popstate #14

Closed
yyx990803 opened this issue Jun 7, 2015 · 9 comments
Closed
Labels
feature request group[current route information] Issues regarding current route information that is currently missing
Projects

Comments

@yyx990803
Copy link
Member

Sometimes different page transitions are needed when clicking a link vs. clicking the back button.

@altitudems
Copy link

Does this mean we can have transitions that go back and forth between pages in a single page app?

I would be happy to see that. Maybe we could eventually get to do something like this?
http://www.appcoda.com/wp-content/uploads/2015/03/vid08.gif

@lesion
Copy link

lesion commented Feb 12, 2016

+1
I would love a way to specify to vue-router that transitions has to be done in reverse order

@vwxyutarooo
Copy link

Is there any updated?

@ccqgithub
Copy link

How about this feature now ?

@chasebank
Copy link

chasebank commented Oct 28, 2017

Until this get's an official solution, the method I've settled for is setting a "depth" meta property for each route. Then when the route changes, check whether the new route depth is higher or lower than the previous. If it's higher, transition from right, if it's lower (going back) transition from left.

Not ideal and could be a nightmare to maintain, but get's the job done for simple implementations.

  { 
    name: 'categories',
    path: '/categories',
    component: categories,
    meta: { depth: 1 },
  },
  { 
    name: 'category',
    path: '/categories/:category/',
    component: category,
    meta: { depth: 2 },
  }
<transition :name="transitionDirection">
  <router-view></router-view>
</transition>
data() {
  return {
    transitionDirection: 'slide-left',
  }
},
watch: {
  '$route' (to, from) {
    const toDepth = to.meta.depth
    const fromDepth = from.meta.depth
    this.transitionDirection = toDepth < fromDepth ? 'slide-right' : 'slide-left';
  }
}
.slide-left-enter,
.slide-right-leave-active {
  transform: translate3d(100%, 0, 0);
  opacity: 0;
}

.slide-right-enter,
.slide-left-leave-active {
  transform: translate3d(-100%, 0, 0);
  opacity: 0;
}

Or, if it's a super simple application, rather than set the depth manually, you can rely on the "depth" of the route path. app/categories < app/categories/:category < app/categories/:category/:post

watch: {
  '$route' (to, from) {
    const toDepth = to.path.split('/').length
    const fromDepth = from.path.split('/').length
    this.transitionDirection = toDepth < fromDepth ? 'slide-right' : 'slide-left'
  }
}

@vuejs vuejs deleted a comment from limichange Dec 4, 2017
@vuejs vuejs deleted a comment from whtsky Dec 4, 2017
@vuejs vuejs deleted a comment from amirrustam Dec 4, 2017
@vuejs vuejs deleted a comment from shenlq Dec 4, 2017
@vuejs vuejs deleted a comment from wjy4124 Dec 4, 2017
@vuejs vuejs deleted a comment from nbagonet Dec 4, 2017
@vuejs vuejs deleted a comment from chasebank Dec 4, 2017
@vuejs vuejs deleted a comment from james-brndwgn Dec 4, 2017
@posva posva added the group[current route information] Issues regarding current route information that is currently missing label Mar 26, 2019
@posva posva added this to Design proposals + discussion (high prio, high complex) in Longterm Mar 26, 2019
@jasonhibbs
Copy link

Transitions are extremely clumsy when using the swipe back gesture on iOS because they fire after the user has already reached the destination.

Being able to disable transitions when a forward/back button or browser gesture is used would be very helpful.

@valgeirb
Copy link

valgeirb commented Nov 1, 2020

Transitions are extremely clumsy when using the swipe back gesture on iOS because they fire after the user has already reached the destination.

Being able to disable transitions when a forward/back button or browser gesture is used would be very helpful.

Have you found a work-around? I'm really struggling with transitions and swipe back gestures on iOS.

@jasonhibbs
Copy link

Have you found a work-around? I'm really struggling with transitions and swipe back gestures on iOS.

I never found a workaround, just this issue

@posva
Copy link
Member

posva commented Jun 21, 2021

Closing in favor of #3453 which would effectively allow this by using $route.navigation.type or similar

@posva posva closed this as completed Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request group[current route information] Issues regarding current route information that is currently missing
Projects
Longterm
Design proposals + discussion (high p...
Development

No branches or pull requests

9 participants