Stop jQuery animations stacking

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-05-18T14:09:09Z Indexed on 2010/05/18 14:10 UTC
Read the original article Hit count: 205

Filed under:
|

I have an Options box that hovers in the top right of the webpage. It's opacity is set to 10% so as not to be obstructive to users. When they hover over (mouseenter) it I use jQuery to fade it in and slidedown the content (and the reverse on mouseout).

If they do this repeatedly though the animation stacks up and you can sometimes be left in a situation where your mouse is stood still but the box is yo-yoing around.

How can I get around this situation?

Here is how I currently setup the animations

$("#dropdown").mouseenter(function() { 
    $(this).fadeTo('fast',1);
    $("#options").slideDown();
});

$("#dropdown").mouseleave(function() { 
    $(this).fadeTo('fast',0.1);
    $("#options").slideUp();
});

Note I am using jQuery only and not any other plugins.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-animation