gpt4 book ai didi

javascript - 当我放映幻灯片时,下拉框菜单停止工作

转载 作者:行者123 更新时间:2023-11-30 06:37:49 24 4
gpt4 key购买 nike

我是网页设计的新手,确实需要一些类项目的帮助。我有一个滑动导航,我正在使用来自 http://tympanus.net/codrops/2010/07/16/slide-down-box-menu/ 的以下 Javascript

<!-- The JavaScript -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript">
$(function() {
/**
* for each menu element, on mouseenter,
* we enlarge the image, and show both sdt_active span and
* sdt_wrap span. If the element has a sub menu (sdt_box),
* then we slide it - if the element is the last one in the menu
* we slide it to the left, otherwise to the right
*/
$('#sdt_menu > li').bind('mouseenter',function(){
var $elem = $(this);
$elem.find('img')
.stop(true)
.animate({
'width':'170px',
'height':'170px',
'left':'0px'
},400,'easeOutBack')
.andSelf()
.find('.sdt_wrap')
.stop(true)
.animate({'top':'140px'},500,'easeOutBack')
.andSelf()
.find('.sdt_active')
.stop(true)
.animate({'height':'170px'},300,function(){
var $sub_menu = $elem.find('.sdt_box');
if($sub_menu.length){
var left = '170px';
if($elem.parent().children().length == $elem.index()+1)
left = '-170px';
$sub_menu.show().animate({'left':left},200);
}
});
}).bind('mouseleave',function(){
var $elem = $(this);
var $sub_menu = $elem.find('.sdt_box');
if($sub_menu.length)
$sub_menu.hide().css('left','0px');

$elem.find('.sdt_active')
.stop(true)
.animate({'height':'0px'},300)
.andSelf().find('img')
.stop(true)
.animate({
'width':'0px',
'height':'0px',
'left':'85px'},400)
.andSelf()
.find('.sdt_wrap')
.stop(true)
.animate({'top':'25px'},500);
});
});
</script>

当我尝试在页面上放映幻灯片时,导航停止工作。我试过几个幻灯片,它们都存在某种类型的冲突。我尝试使用的那个来自 http://www.jacklmoore.com/monte .

感谢您的帮助。

最佳答案

您一次性多次调用 animate 和 stop。处理此问题的两种方法是构建队列系统 ( jQuery does have one ),或使用提供的回调(在函数完成其工作后运行的函数)。

需要说明的是,像这样的代码都是一次性运行的:

a.animate1()
b.animate2() //animate2 doesn't wait for animate 1, thus, use of callbacks and/or queues.

作为旁注,看看您是否可以通过使用函数来减少您使用大量剪切+粘贴的代码部分。祝项目顺利!

关于javascript - 当我放映幻灯片时,下拉框菜单停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13434694/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com