I’m playing with Giva Labs jQuery Marquee plugin. Example jsFiddle here.
There are two toggling lines of text in the example: First line and Second row. When you start to continuously move mouse cursor over and out the light-blue box, the text goes crazy: the lines start to move over each other like randomly, out of order. The craziness is strongest when you change speed of mouse movements from slow to fast in a loop.
I googled for “jquery animate stop” and found the .stop() and .clearQueue() effects. I tried attaching these to the marquee effect like this:
$("#marquee").marquee().stop();
and this:
$("#marquee").marquee().clearQueue();
and also like this:
$("#marquee").marquee()
.hover(function() {
$(this).clearQueue();
});
I also tried with the plugin’s build-in methods:
$("#marquee").marquee()
.hover(function() {
$(this).marquee("pause");
})
.mouseout(function() {
$(this).marquee("resume");
});
None of them worked.
How to get rid of this glitch?
UPDATE/SOLVED:
Code: jsFiddle
Solution summary:
var timedouttimedoutinsidescroll()clearTimeout(timedout)insidepause()The bug doesn’t occur when you put a very low
pauseSpeed(like 2 for example), which leads me to believe the bug it happens because of the interaction betweenpause()andresume()Concretely, this bit of code in
pause():this bit of code in
resume():and this bit of code in
scroll():As far as I can see the problem occurs because
dequeue().stop()[which makes sense] is immediate and andscroll(...)has some code that happens with a delay (pauseSpeed).So what happens is the following:
pause()resume()callsscroll()which in turns sets a timeout function to occur in 2000 msTo fix this I would suggest editing
jquery.marquee.jscode and actually callingclearTimeout()every time you stop the animation.