JSFiddle - React, Tailwind, and code Playground
HTML
<button>clickMe</button>
<div></div>
<span></span>
CSS
div{
width:0px;
height:20px;
background-color:#f99;
}
JavaScript
var flag=true;
$('button').on('click',e=>{
if (flag) {
$('div').stop().css({width:0});
$('div').animate({width:100},{
duration:5000,
step: (now, fx)=>{
$('span').text(now);
if (now>80&&!flag) console.log(flag=true)
}
})
flag = false;
}
});