JSFiddle - React, Tailwind, and code Playground
by kurotanshi
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<script src="https://unpkg.com/[email protected]/dist/vue.global.js"></script>
<div id="app">
<div class="wrap">
<button
v-for="c in animateClasses"
@click="activedAnimate(c)"
>{{ c }}</button>
</div>
<div ref="block" class="block" :class="animatedClassName">Block</div>
</div>
SCSS
#app {
position: relative;
display: block;
padding: 1rem;
font-size: 1rem;
}
button {
font-size: 1rem;
}
.block {
display: block;
width: 120px;
height: 80px;
line-height: 80px;
text-align: center;
font-size: 1.2rem;
margin-top: 1rem;
background-color: #3eaf7c;
color: #fff;
}
.wrap {
display: block;
margin-bottom: 1.5rem;
button {
margin-right: 1rem;
margin-bottom: 1rem;
}
}
JavaScript
const app = Vue.createApp({
data() {
return {
animateClasses: [
'bounce',
'rubberBand',
'tada',
'shakeY',
'shakeX',
],
animatedClassName: ''
}
},
methods: {
activedAnimate(className){
this.animatedClassName = `animate__animated animate__${className}`;
}
}
});
app.mount('#app');