JSFiddle - React, Tailwind, and code Playground
by george_black
HTML
<div id="object1"></div>
<div id="object2"></div>
CSS
#object1, #object2{ position: absolute; left: -200px; top: 0px;}
#object1 { background-color: #ff0000; z-index:10; height: 20px; width: 100px; }
#object2 { background-color: #000099; z-index:10; height: 20px; width: 100px;}
JavaScript
var animateMe = function(targetElement, speed){
$(targetElement).css({left:'-200px'});
$(targetElement).animate(
{
'left': $(document).width() + 200
},
{
duration: speed,
complete: function(){
animateMe(this, speed);
}
}
);
};
animateMe($('#object1'), 5000);
animateMe($('#object2'), 3000);