JSFiddle - React, Tailwind, and code Playground
by mikapon
HTML
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/anime.min.js"></script>
<div class="borad" onclick="start()">
<div class="ball"></div>
</div>
CSS
.board {
width: 400px;
height: 300px;
position: relative;
}
.ball {
width: 25px;
height: 25px;
border-radius: 25px;
background-color: blue;
}
JavaScript
var one = anime({
targets: '.ball',
duration: 500,
keyframes: [
{translateX: 240},
{translateY: 100}
],
delay: 10,
easing: 'easeInOutCirc',
autoplay: false,
update: function(anim) {
console.log(anim)
}
})
function start() {
one.seek(0)
one.play()
}