I know the typical way for doing animations in Vue.js, adding the transition="my-animation"
on the HTML element.
I'm wondering if can I call explicitly that animation form code and not just depending on v-show
/ v-if
.
I'd like to "shake" a component (A) each time another one (B) is clicked. For that I use a pulse
transition (from animated.css).
For the moment B dispatches a message each time is clicked.
A receives the message and sets it's property animate
to true. Then A shakes thanks to, in the HTML:
<div id="A" class="animated"
transition="pulse"
v-show="show"
v-bind:class="{ 'pulse': animate }"
>
Onces it's being animated, won't do it anymore, since A's animate
prop is already set to true. I'd need to reset it to false so on next click the component could shake again.
I've tried with the transition hooks:
Vue.transition('pulse', {
afterLeave: function (el) {
this.animate = false;
},
})