JSFiddle - React, Tailwind, and code Playground
HTML
<div class="cair"></div>
CSS
.cair {
position: absolute;
top: 0px;
padding: 30px;
height: 50px;
width: 50px;
background-color: #ccf;
}
JavaScript
$(function () {
var inicio;
var fim = 385;
$(".cair").animate({
top: fim + "px",
}, {
duration: 6000,
"complete": function () {
$('.cair').remove();
},
start: function () {
inicio = window.getComputedStyle(this).top.replace('px', '');
},
progress: function (a, p, r) {
var valorAtual = p * (fim - inicio);
if (Math.round(valorAtual) == 200) alert('chegámos aos 200px!');
}
});
});