I'm trying to implement something similar to a news ticker, except I don't know the size of the text that is being scrolled. The end of the text has to be followed immediately by the beginning of the text (wrapped). My current solution involves me duplicating the text to make it look infinite, but I'm having issues getting it to look seamless.
Currently I have this: http://jsfiddle.net/theintellects/e7td1g0w/1/
Code in question:
var containerwidth = $ticker.width();
var left = containerwidth;
var width = $tickerText.width();
function tick() {
if (--left < -width) {
left = 0;
}
$tickerText.css("margin-left", left + "px");
setTimeout(tick, settings.speed);
}
tick();
You'll notice that the text wraps around but there is a breakpoint where I reset the left-margin, and causes a "jump". Is there any way to make this seamless? I'd prefer not to have to keep appending the string to itself and allow it to scroll forever to the left.