JSFiddle - React, Tailwind, and code Playground
by luizz
HTML
<div id="anime" data-time="3000"></div>
CSS
body{
width: 500px;
}
#anime{
position:absolute;
width:200px;
background:#000;
height:200px;
color:#FFF
}
JavaScript
$(function (){
var bodyWidth = ~~($('body').width());
function loopElemento(){
var alvo = $('#anime');
var time = ~~alvo.attr('data-time'), width = ~~alvo.width();
alvo.animate({left: "+=" + ~~(bodyWidth + width + Math.abs(alvo.offset().left))}, time)
.animate({left:"-" + width}, 0, loopElemento);
}
loopElemento('#anime');
});