In order to create a continuous wall that pulls text from a database and displays it, I've developed the following code:
$(function() {
var x = 0;
var y = 100.0;
var z=0;
setInterval(function() {
x -= 0.1;
y -= 0.1;
z++;
if (x <= -100.0){
$("#h1d1").html("loop div 1 :" + z);
x = 0;
}
if (y <= 0){
$("#h1d2").html("loop div 2 :" + z);
y = 100.0;
}
$('#movimg1').css('left', x + "%");
$('#movimg2').css('left', y + "%");
}, 10);
$("#stopbutton").click(function() {
$('#movimg1').stop();
});
})
However, the behavior of the text is not as desired, changing in the middle of the screen when it should update only when out of view. https://jsfiddle.net/oa0wdxcx/2/
I also aim to incorporate a play/pause button. Any tips on achieving this functionality would be greatly welcomed. Additionally, I'd like the divs to be contained within the #wrap div, but altering the position attribute to relative causes them to move apart.
Thank you in advance.