arsenalist
arsenalist

Reputation: 391

jQuery slideup and down feature delay

I have a few images with a div and header on it that when mouse entering it slides up and leaving vise versa. It works, however the slidedown doesn’t happen right away. So, if I hover the mouse over it a few times quickly (lets say 10 times) it will slide up and down for like 30 seconds. I know there is something wrong in my code. Any ideas?

$(document).ready(function(){

    $('.indexgall').on('mouseenter',function(){
        $(this).addClass('hoverimg');
        $(this).children().animate({
            top:150
        },600,function(){
        });
    });

    $('li').on('mouseleave',function(){
        $(this).removeClass('hoverimg');
        $(this).children().animate({
            top:250,
        },600,function(){
        });
        $(this).stop().animate({});
    });

}); // END DOCMENT READY

.hoverimg
{
    box-shadow: .2% .2% .2% gray;    /*2px 2px 2px gray */
    opacity: 0.8;
}

JsFiddle

Upvotes: 0

Views: 54

Answers (1)

John S
John S

Reputation: 21492

Animations queue up when called on the same element. You should call .stop() before you call .animate().

$(this).children().stop().animate({

Upvotes: 1

Related Questions