question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When v-if and v-show are used on the same element, leave transition does not occur when v-if changed to false

See original GitHub issue

Vue.js version

2.1.3

Reproduction Link

http://codepen.io/weotch/pen/GNyWaV

Steps to reproduce

Go to that codepen and click both links for “show” and “if” to “yes”. Toggle just “show” off, note the transition occurs. Toggle “show” back on and then toggle “if” off, note that there is no transition out.

What is Expected?

I expected to still see the box transition out. Or, in other words, anenter transition should trigger only if both v-show and v-if == true. And a leave transition should trigger only if either v-show or v-if != true.

What is actually happening?

If v-if == true and v-show changes from true to false, the leave transition occurs as expected. If v-show== true and v-if changes from true to false, the element is immediately removed, no transition occurs.

My use case for this is using both v-if and v-show around media (img, video). The v-if triggers a load to start and then, once they are loaded, the v-show triggers the element to be revealed.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
yyx990803commented, Dec 1, 2016

v-if and v-show are not supposed to be used together for transition purposes, because they entail conflicting start/ending states. Regarding your use case: you can use the v-if on the outer <transition> component instead.

0reactions
sky790312commented, Oct 23, 2017

Got it. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enter/Leave & List Transitions - Vue.js
CSS animations are applied in the same way as CSS transitions, the difference being that v-enter is not removed immediately after the element...
Read more >
vue fade transition only work when element is leaving and not ...
In Vue 3, the transition class name has changed from -enter to -enter-from , so your classes should be renamed accordingly to allow...
Read more >
Add, change, or remove transitions between slides
Slide transitions are the animation-like effects that occur when you move from one slide to the next during a presentation. You can control...
Read more >
v-if vs. v-show - Vue Conditional Rendering - LearnVue
Your browser can't play this video. ... Conditional rendering is the ability to control whether or not template code is rendered.
Read more >
Animation transitions - Unity - Manual
Exit Time is a special transition that doesn't rely on a parameter. Instead, it relies on the normalized time of the state. Check...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found