JQuyer slide and stop issues: animated element freezes with quick mouse movement
Posted
by
sherlock
on Stack Overflow
See other posts from Stack Overflow
or by sherlock
Published on 2013-06-27T22:11:03Z
Indexed on
2013/06/27
22:21 UTC
Read the original article
Hit count: 193
JavaScript
|jQuery
Here is Zi JsFiddle. In order to replicate my issue you have to hover over the link that says 'javascript', then mouseout that, then mouseback in. If you do this before the animation is complete, the pink slidedown #subMenu
will freeze midway through sliding. Is there a way to prevent this from happening? I have tried some .stop()
s , but i really don't want the animation to re-start every time you mouseenter or leave the .navLink
. The animation should begin from where it left off. In other words, if the pink section is halfway down, and a slideDown() gets executed, the pink should not dissappear and then slide down, it should slide down from where it is.
Thanks!!
JS:
$('header#subHeader').hide();
$('.navLink').hover(function () {
if ($(this).children('div').length > 0) {
var subMenu = $(this).find('.subMenu').html();
$('header#subHeader').empty().append('<div>' + subMenu + '</div>').stop().slideDown();
} else {
$('header#subHeader').stop().slideUp();
}
});
$('hgroup:first').on('mouseleave', function(){
$('header#subHeader').slideUp();
});
© Stack Overflow or respective owner