简体   繁体   English

jQuery动画没有完成(slideUp / slideDown)

[英]jQuery animate doesn't complete (slideUp/slideDown)

I have a web interface to a system which has a left navigation. 我有一个系统的Web界面,该系统具有左侧导航。 On the navigation, I can expand/collapse some menus. 在导航上,我可以展开/折叠一些菜单。 I use jQuery slideUp/slideDown to animate them like this: 我使用jQuery slideUp / slideDown为它们设置动画:

if (enable)
{
    navbar_slide_down = true;
    $j(l1_folder).slideDown("normal", function() {
        navbar_slide_down = false;

        on_navbar_animation_complete();
    });
}
else
{
    navbar_slide_up = true;
    $j(l1_folder).slideUp("normal", function() {
        navbar_slide_up = false;

        on_navbar_animation_complete();
    });
}

Both animations run simultaneously to provide an accordion-like effect. 两种动画同时运行以提供类似手风琴的效果。 This works in nearly all cases. 这几乎适用于所有情况。

The problem I'm encountering now is that after performing some actions in a content frame (not the same frame as the navigation), the slideDown and slideUp functions no longer work. 我现在遇到的问题是,在内容框架(与导航不同的框架)中执行了一些操作之后,slideDown和slideUp函数不再起作用。 The animations start, but stop nearly immediately, and the callback is never fired. 动画开始但几乎立即停止,并且永远不会触发回调。 This causes the menu to lockup. 这将导致菜单锁定。 I can only reproduce this issue in FireFox 3.5.7 (other versions seem OK). 我只能在FireFox 3.5.7中重现此问题(其他版本似乎还可以)。 If I turn on Firebug, the problem doesn't occur. 如果我打开Firebug,则不会发生此问题。

I've tried upgrading from jQuery 1.3.2 to 1.4.1, no luck. 我已经尝试从jQuery 1.3.2升级到1.4.1,没有运气。

Is there any reason the animations would fail and not call the callback? 动画是否有任何原因会失败并且不调用回调? How can I debug this with an unminified jQuery? 如何使用未缩小的jQuery调试它?

The problem was sequence dependent (ie: click on this, and then that, and the hang will occur). 问题是与序列有关的(即:先单击,然后单击,然后挂起)。 I found the problem in the first page: 我在第一页中发现了问题:

addEvent(window, 'unload', end_page);

And changed it to: 并将其更改为:

addEvent(window, 'onbeforeunload', end_page);

I'm still not sure why this would effect the outer frame (and cause jQuery animations to break), but my best guess is that code in the unload handler was running on the second page and conflicting somewhere. 我仍然不确定为什么这会影响外部框架(并导致jQuery动画中断),但是我最好的猜测是卸载处理程序中的代码在第二页上运行并且在某处发生冲突。

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

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