Code Monkey home page Code Monkey logo

Comments (9)

ccqgithub avatar ccqgithub commented on May 16, 2024 2

How about this feature now ?

from vue-router.

chasebank avatar chasebank commented on May 16, 2024 2

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'
  }
}

from vue-router.

jasonhibbs avatar jasonhibbs commented on May 16, 2024 2

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.

from vue-router.

altitudems avatar altitudems commented on May 16, 2024

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

from vue-router.

lesion avatar lesion commented on May 16, 2024

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

from vue-router.

vwxyutarooo avatar vwxyutarooo commented on May 16, 2024

Is there any updated?

from vue-router.

valgeirb avatar valgeirb commented on May 16, 2024

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.

from vue-router.

jasonhibbs avatar jasonhibbs commented on May 16, 2024

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

from vue-router.

posva avatar posva commented on May 16, 2024

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

from vue-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.