Search code examples
jquerycallbackscrolljquery-animatedelay

jquery: animate scrollLeft with unwanted delay to callback function


I'm just starting to use jQuery. I've been using Greensock for most of my animations, so I apologize if this is a dumb question. But, I'm trying to do a news ticker type thing where it scrolls text to the left, and when it ends, it resets and starts over. I have it mostly working, but, for some reason, I have a delay to the callback function to reset it's position and I have no clue why (and I don't want it). My animation call looks like this:

tt.animate({
    scrollLeft: parseInt(tt.width())
}, 10000, 'linear', backToStart);

Original HTML:

<div id="ticker">
    <div id='tickerholder'>
        <div id='tickertext'></div>
    </div>
</div>

And here is a link to see the example: http://jsfiddle.net/ctf7L/1/

Thanks for any help!


Solution

  • Apparently my issue was using scrollLeft. I added an extra div above the text, and then animated the left position of the text instead... totally works http://jsfiddle.net/ctf7L/3/ I put ** by the new div I added.

    <div id="ticker">
        <div id='tickerholder'>
            **<div id='tickerbackground'>**
                <div id='tickertext'></div>
            **</div>**
        </div>
    </div>