1

I'm trying to implements a transition between two elements containing CSS animations simply by following the documentation's example.

My HTML contains : A button to change my state :

<button @click="toggled = !toggled">
  Toggle class ({{ toggled }})
</button>

The transition with the two loader (a red and a black one) :

<transition name="fade" mode="out-in">
  <div class="loader" v-if="toggled" key="toggled"></div>
  <div class="loader red" v-else key="notToggled"></div>
</transition>

It appears that the VueJS's transition is waiting for the animation to finish before displaying the next. Am I doing something wrong ?

Reproduce the issue : https://jsfiddle.net/f2vozp35/2/

2
  • Could you explain in a little more detail what you're trying to achieve? Commented Aug 29, 2017 at 11:38
  • Sorry if the post wawsn't explicit enough, I was just trying to achieve what @Stephan-v shown, to have my transition running "smoothly" and not with the delay that you can see in the Fiddle. Commented Aug 29, 2017 at 12:03

2 Answers 2

4

This is what you are looking for:

https://v2.vuejs.org/v2/guide/transitions.html#Explicit-Transition-Durations

Updated fiddle:

<transition name="fade" mode="out-in" :duration="300">

https://jsfiddle.net/f2vozp35/3/

Vue.js will try to be smart about the transition and will wait for your animation to finish, this way you can explicitly define the duration between the transition.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank, that was it. I though it was due to the animation time of the loaders (since modifying these timers shorten the time of the delay).
-2

Try removing key for your divs

<transition name="fade" mode="out-in">
    <div class="loader" v-if="toggled"></div>
    <div class="loader red" v-else></div>
</transition>

1 Comment

The keys are used by the transition, if I remove them the transition doesn't happen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.