1
我试图给一个推出框添加动画以显示该区域要做的事情列表。停止Jquery .Animate()新的.Animate()
不幸的是,如果您快速点击2个或更多个框,它会展开所有点击的框,然后再次锁定框。
你可以点击任何未选定的盒子,但我不能在我的生活中防止他们两个出现在同一时间的问题。
我不是100%确定我正确使用.stop命令。
请帮忙!
这是我的代码。这里还有一个jsfiddle链接,附带一些演示。 http://jsfiddle.net/hceFT/4/
$(document).ready(function() {
$("#attractionsbox").css({ width:0 });
$("#entertainmentbox").css({ width:0 });
$("#diningbox").css({ width:0 });
$("#attractionspointer").css({ width:0 });
$("#entertainmentpointer").css({ width:0 });
$("#diningpointer").css({ width:0 });
$("#experiences").css('overflowY' , 'hidden');
});
$("#freefunbutton").click(function() {
if ($("#freefunbox").width()) {} else {
$(".contentbox").stop(true, false).animate({
width: 0
}, 200, function() {
$(".pointer").animate({
width: 0
}, 50, function() {
$("#freefunpointer").animate({
width: 40
}, 50, function() {
$("#freefunbox").animate({
width: 500
}, 200);
});
});
});
}
});
$("#attractionsbutton").click(function() {
if ($("#attractionsbox").width()) {} else {
$(".contentbox").stop(true, false).animate({
width: 0
}, 200, function() {
$(".pointer").animate({
width: 0
}, 50, function() {
$("#attractionspointer").animate({
width: 40
}, 50, function() {
$("#attractionsbox").animate({
width: 500
}, 200);
});
});
});
}
});
$("#entertainmentbutton").click(function() {
if ($("#entertainmentbox").width()) {} else {
$(".contentbox").stop(true, false).animate({
width: 0
}, 200, function() {
$(".pointer").animate({
width: 0
}, 50, function() {
$("#entertainmentpointer").animate({
width: 40
}, 50, function() {
$("#entertainmentbox").animate({
width: 500
}, 200);
});
});
});
}
});
$("#diningbutton").click(function() {
if ($("#diningbox").width()) {} else {
$(".contentbox").stop(true, false).animate({
width: 0
}, 200, function() {
$(".pointer").animate({
width: 0
}, 50, function() {
$("#diningpointer").animate({
width: 40
}, 50, function() {
$("#diningbox").animate({
width: 500
}, 200);
});
});
});
}
});
谢谢,我最终在每个.animate()之前替换了.stop并放置了.clearQueue()。 .stop工作,但我认为clearQueue可能是一个更好的使用。如果可以的话,我会投票,但显然我需要15个代表投票。 – Fidgeter
很高兴为你效劳=) –