简体   繁体   English

如果在jquery .slideDown()动画结束之前未触发Javascript侦听器

[英]Javascript listener not firing if before end of jquery .slideDown() animation

simple one i hope! 我希望简单!

The problem im having is that i have an ('itemID').mouseover, which fires a jquery slide-down animation for a menu box. 我遇到的问题是我有一个('itemID')。mouseover,它会为菜单框触发一个jquery下拉动画。 The problem is that if the mouse leaves the original item (in this case a text link) before the end of the slideDown() amination, the .mouseleave function is not called. 问题是,如果鼠标在slideDown()胺化作用结束之前离开了原始项目(在这种情况下为文本链接),则不会调用.mouseleave函数。

It works fine otherwise!! 否则效果很好!!

This is what im using: (menu14 is the text link, FunctionsMenu3 is the hidden div containing the menu items) 这就是即时通讯使用的内容:(menu14是文本链接,FunctionsMenu3是包含菜单项的隐藏div)

$('#menu14').mouseover(function() {
   $('#FunctionsMenu3').slideDown('fast', function() {
    // Animation complete.
  });
});

$('#FunctionsMenu3').mouseleave(function() {
   $('#FunctionsMenu3').slideUp('fast', function() {
    // Animation complete.
  });
});

It seem to me that the JS CANT be fired, because its busy doing the slide... site can be seen at http://www.impero-classroom-management.com thanks in advance!! 在我看来,JS CANT被解雇了,因为它忙于做幻灯片...该网站可以在http://www.impero-classroom-management.com上看到,谢谢!!

Well i got around it in the end by not animating the drop down, only the slide up. 好吧,我最后通过不动画下拉菜单,只滑动了动画来解决它。

not a fix, but it was all i could really do!! 不是解决办法,但这是我真正能做的!

$('#FunctionsMenu5').mouseleave(function() {
   $('#FunctionsMenu5').slideUp('fast', function() {
    // Animation complete.
  });
});
$('#menu15').mouseover(function() {
   $('#FunctionsMenu5').show();
});

On mouseleave, try .stop() to cancel the current animation. 在mouseleave上,尝试.stop()取消当前动画。

$('#menu14').hover(
  function() {
   $('#FunctionsMenu3').slideDown('fast');
  },
  function() {
   $('#FunctionsMenu3').stop().slideUp('fast');
  }
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM