Vue-router: Change dynamically visual transitions based on transition.from and to transition.to

Created on 22 Apr 2016  路  3Comments  路  Source: vuejs/vue-router

Vue.js & vue-router.js version

1.0.20, 0.7.12

Reproduction Link

http://codepen.io/lbineau/pen/XdBMwG

What is Expected?

I want to dynamically change the visual transition between pages, according to the page I am and the page I'm going.

What is actually happening?

I'm using the beforeEach hook to change the visual transition with the "transition.from" and "transition.to" parameters.
The leaving component has the old transition and the entering component has the new transition.

Am I doing something wrong or is there another way to do it ?

Most helpful comment

I found the solution, just call the transition.next into Vue.nextTick in order to wait Vue refresh all the variable before continuing the transition.

Vue.nextTick(transition.next);

updated demo: http://codepen.io/lbineau/pen/QNBMdv

All 3 comments

@simplesmiler Thanks for reply so fast. This hack is really smart and works very well, but what about if I want also to dynamise the transition-mode ? (in-out out-in)

I found the solution, just call the transition.next into Vue.nextTick in order to wait Vue refresh all the variable before continuing the transition.

Vue.nextTick(transition.next);

updated demo: http://codepen.io/lbineau/pen/QNBMdv

Was this page helpful?
0 / 5 - 0 ratings

Related issues

posva picture posva  路  3Comments

rr326 picture rr326  路  3Comments

achen224 picture achen224  路  3Comments

druppy picture druppy  路  3Comments

baijunjie picture baijunjie  路  3Comments