I want to dynamically change what kind of animation happens depending on a user's action. So for example, when the first button is clicked and the leave animation is called the "hello" element should use the bounceOutRight animation. However, if the user clicks the second button the "hello" element should use the bounceOutLeft animation. This example comes from the vue.js documentation and I am trying to expand on it. As in the vue example it uses the animate.css library.
I tried using v-bind:leave-active-class="animated bounceOutRight" but that threw an error as an invalid expression.
<button @click="show = !show">
Toggle Bounce Right
</button>
<button @click="show = !show">
Toggle Bounce Left
</button>
<transition
name="custom-classes-transition"
enter-active-class="animated tada"
leave-active-class="animated bounceOutRight"
>
<p v-if="show">hello</p>
</transition>
vue-kinesisIt's a powerful animation tool that can be used by developers to create superb animations. It also allows the use of various custom attributes to help achieve the desired effect.
<TransitionGroup> is a built-in component designed for animating the insertion, removal, and order change of elements or components that are rendered in a list.
You can use v-bind for this purpose, you can have name of transition as vue data variable and following will make sure it is dynamic:
<transition
v-bind:name="className"
v-bind:enter-active-class="enterClassName"
v-bind:leave-active-class="leaveClassName"
>
or in short
<transition
:name="className"
:enter-active-class="enterClassName"
:leave-active-class="leaveClassName"
>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With