Answer the question
In order to leave comments, you need to log in
Is it possible to animate one component on vue.js?
I'm trying to figure out animation in vue.js, there is a component that reflects the image slider element in itself, so an animated transition between several of them is needed. Without animation, everything works fine, the pictures are flipped in the right order, so about the logic here, in general, everything is okay. Based on the vue.js documentation, I wrote the following piece of code:
<transition name="fade">
<slide-item v-if="state == 'first'"
:url="sources[number]"
@next="next"
>
</slide-item>
<slide-item v-else-if="state == 'second'"
:url="sources[nextNumber]"
@next="next"
>
</slide-item>
</transition>
.fade-enter {
}
.fade-enter-active {
animation: fadeIn .3s linear;
}
.fade-leave {
}
.fade-leave-active {
animation: fadeOut .3s linear;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
Answer the question
In order to leave comments, you need to log in
Here is your solution
. Usually you only need to wrap one block in a transition, and you are trying to cram two into it. Just split them into two transits and that's it.
If you need a smooth appearance, but there is no need to use animation, a simple transition is enough .
You just need to either put down so that the components overlap each other and do not jump, or specify - Transition Modes . position: absolute
mode="out-in"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question