jQuery 等待一个动画完成后再开始另一个动画
我有一组选项卡,这些选项卡会导致某些带有选项的 DIV 在父 DIV 顶部“飞出”。内容通过 AJAX 获取。
弹出窗口是在单击时调用的,所以
$('.fly_out').live('click', function() {
var $widget = $(this).closest('.widget');
var $flyOutIndex = $(this).index('.fly_out');
if ($flyOutIndex == 0) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/Priceassessment/product_order.htm';
} else if ($flyOutIndex == 1) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_comparisons.htm';
} else if ($flyOutIndex == 2) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_scenarios.htm';
} else if ($flyOutIndex == 3) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_analysis.htm';
}
// Close any open flyouts
closeFlyout();
$.ajax({
type: 'GET',
url: DashboardApplicationRoot + $flyOutURL,
dataType: 'html',
cache: false,
success: function(data) {
$($widget).prepend(data);
$('.fly_container').animate({ 'right': '0' }, 'fast');
$('.scroll').jScrollPane();
$('.striped li:nth-child(even)').addClass('odd');
}
});
return false;
});
我有一个关闭弹出窗口的函数:
function closeFlyout() {
$('.fly_container').animate({
'right': '-332'
}, 'fast', 'swing', function() {
$(this).detach();
});
};
当单击另一个弹出窗口选项卡以及单击弹出窗口本身中包含的关闭按钮时会调用该函数:
$('.fly_container .close').live('click', function() {
closeFlyout();
return false;
});
我想扩展它,以便如果某个浮出控件已打开,并且用户单击以初始化另一个浮出控件,则打开的浮出控件会以动画方式关闭,但新的浮出控件会等待此动画完成,然后再显示新的浮出控件。
I have a set of tabs which cause certain DIVs with options to 'fly out' over the top of a parent DIV. The content is pulled in via AJAX.
The fly outs are called on click like so
$('.fly_out').live('click', function() {
var $widget = $(this).closest('.widget');
var $flyOutIndex = $(this).index('.fly_out');
if ($flyOutIndex == 0) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/Priceassessment/product_order.htm';
} else if ($flyOutIndex == 1) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_comparisons.htm';
} else if ($flyOutIndex == 2) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_scenarios.htm';
} else if ($flyOutIndex == 3) {
$flyOutURL = 'Content/HTMLSnippets/Flyouts/PriceHistory/price_history_analysis.htm';
}
// Close any open flyouts
closeFlyout();
$.ajax({
type: 'GET',
url: DashboardApplicationRoot + $flyOutURL,
dataType: 'html',
cache: false,
success: function(data) {
$($widget).prepend(data);
$('.fly_container').animate({ 'right': '0' }, 'fast');
$('.scroll').jScrollPane();
$('.striped li:nth-child(even)').addClass('odd');
}
});
return false;
});
I have a function to close the flyouts:
function closeFlyout() {
$('.fly_container').animate({
'right': '-332'
}, 'fast', 'swing', function() {
$(this).detach();
});
};
Which is called when another fly out tab is clicked and also when clicking a close button contained within the fly out itself:
$('.fly_container .close').live('click', function() {
closeFlyout();
return false;
});
I would like to extend this so that if a fly out is open and a user clicks to initialise another flyout, then the open flyout animates shut but the new fly out waits for this animation to finish before showing the new fly out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果弹出窗口打开时发出信号的全局变量怎么样?然后使用计时器调用单击事件,直到动画完成。
What about a global var that signals if a flyout is open? Then use a timer to invoke the click event until the animation completes.
如果你添加一个怎么样
how about if you add an