views:

1815

answers:

2

I have a simple unordered list with listitems as menu item i created the jquery just to have a funny rolover effect beeing:

$('#nav ul ul li').hover(function(){
$(this).animate({ 
        marginLeft: "20px",
      }, 300 );
}, function(){
$(this).animate({ 
        marginLeft: "0px",
      }, 300 );
});

the problem with this script is, if you rush over the menu several times, an animation queue builds up. i tried to use .stop() inbetween, but then it also stops the animations from the other listitems which should return to default state in any case. is there a way to stop() the queue per item? but not for the whole list?

Sander

+3  A: 

I don't see why $(this).stop().animate(...) is not working for you, but you can also try this approach:

$(":not(:animated)", this).animate(...)

which will only trigger the animation on elements that are not currently animated

duckyflip
where would you add the stop() then?because what i have with stops, is that if you rush over the whole list, the 10th item for example uses stop then animates his way to 20 pixels to the right, but the stop prevented previous items 1 - 9 from returning to default state. 20pixels left.
Sander
uuhm, Sander I'm not sure I understand the exact issue you are having, could you please post your js/html online http://jsbin.com
duckyflip
hm, i just now realize my mistakei added the .stop() @ the end, after the animate.i used it like you do (before) and that seem to work ok.thanksyes the result can be seen @ www.komtuveu.be (left menu)though this is just simple html ol list with text,now i can style it and add the image. thanks
Sander
A: 

hi, could you please tell me how to where in your code use the .stop()? or where exactly the "$(":not(:animated)", this).animate(...)" one? thanks... gabe