Here is the code I have:
HTML
<div class="screen screen1"></div>
<div class="screen screen2"></div>
CSS
.screen{
width: 100%;
height: 50%;
position: absolute;
background-color:#001;
background-image: radial-gradient(white 15%, transparent 16%),
radial-gradient(white 15%, transparent 16%);
background-size:60px 60px;
background-position: 0 0, 30px 30px;
}
.screen2{
left: 100%;
}
JavaScript
$(document).ready(function(){
screen1 = $('.screen1');
screen2 = $('.screen2');
move(screen1, screen2);
});
function move(first, second){
first.animate({left: '-100%'}, 3000, function(){
first.css('left', '100%');
move(second, first);
});
second.animate({left: 0}, 3000);
}
I am trying to create an infinite repeating background animation with two divs using jQuery. The animation works well, but there is a small pause when moving .screen1
to the right.
Here is the link to the fiddle:
https://jsfiddle.net/mavisme/a1275tuv/
How can I fix this pause and make the animation run smoothly?