So I am trying to animate an SVG. When applying animation delay to each path it works properly in v-leave-active class but doesn't work at all in v-enter-active and behaves weird. Check the code below and please help. Run the snippet and click on the button "click" then again click to see the exact problem happening.
const { createApp } = Vue
createApp({
data() {
return {
show: false
}
}
}).mount('.app')
.svg{
max-width: 100px;
margin-left: 50px
}
/* Enter Animation */
.forwardOne-enter-active{
animation: fade-in 0.2s;
}
.forwardTwo-enter-active{
animation: fade-in 0.2s;
animation-delay: 0.3s;
}
.forwardThree-enter-active{
animation: fade-in 0.2s;
animation-delay: 0.6s;
}
/*Leave Animation*/
.forwardOne-leave-active {
animation: fade-in 0.2s reverse;
}
.forwardTwo-leave-active {
animation: fade-in 0.2s reverse;
animation-delay: 0.3s;
}
.forwardThree-leave-active {
animation: fade-in 0.2s reverse;
animation-delay: 0.6s;
}
@keyframes fade-in {
0% {
opacity: 0;
}
50% {
transform: 0.5;
}
100% {
transform: 1;
}
}
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<div class="app">
<button class="right" @click="show = !show">
Click
</button>
<button class="svg">
<svg fill="#000" viewBox="0 0 24 24" stroke="3px">
<g>
<Transition name="forwardThree">
<path v-show="show" d="M15.14,5.46V18.57l8.32-6.64ZM15.87,7l6.42,5-6.42,5.12Z"/>
</Transition>
<Transition name="forwardTwo">
<path v-show="show" d="M15.51,11.37l-.37-.28L7.86,5.43V18.54l7.28-5.81.73-.58v-.49ZM8.6,17V6.92l6.41,5Z"/>
</Transition>
<Transition name="forwardOne">
<path v-show="show" d="M8.23,11.41l-.37-.29L.54,5.43V18.54l7.32-5.85.37-.29.37-.3v-.41ZM1.28,17V6.92l6.41,5Z"/>
</Transition>
</g>
</svg>
</button>
</div>
You can see that first time it does not work but on second click it works properly. I have no idea why this is happening