并行 jQuery 效果

发布于 2024-12-21 22:06:07 字数 381 浏览 4 评论 0原文

我想并行执行两个效果。 jQuery UI“转移”动画和另一个元素上的“淡入”动画。它们应该同时开始和结束。

到目前为止我的代码:

    $('#foo').hover(function() {
        $(this).effect("transfer", {
            to: "#transition-target",
            className: "ui-effects-transfer"
        }, 300, function() {
            $('#bar').fadeIn(300);
        });
    });

我知道这两种效果都是依次执行的。是否可以实现并行效果执行?

I want to execute two effects in parallel. A jQuery UI "transfer" animation and a "fadeIn" on another element. They should begin and end at the same time.

My code so far:

    $('#foo').hover(function() {
        $(this).effect("transfer", {
            to: "#transition-target",
            className: "ui-effects-transfer"
        }, 300, function() {
            $('#bar').fadeIn(300);
        });
    });

I understand that both effects are executed one after another. Is it possible to achieve parallel effect execution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情话难免假 2024-12-28 22:06:07

您在效果的“回调”中具有 fadeIn 函数。仅在动画完成后才会触发/运行回调。这应该可以帮助你..

$('#foo').hover(function() {

    $(this).effect("transfer", {
        to: "#transition-target",
        className: "ui-effects-transfer"
    }, 300);

    $('#bar').fadeIn(300);

});

You had the fadeIn function in the "callback" of the effect. The callback is triggered/run only after the animation has finished. This should help you out..

$('#foo').hover(function() {

    $(this).effect("transfer", {
        to: "#transition-target",
        className: "ui-effects-transfer"
    }, 300);

    $('#bar').fadeIn(300);

});
墟烟 2024-12-28 22:06:07
 $('#foo').hover(function() {
$('#bar').fadeIn(300);
        $(this).effect("transfer", {
            to: "#transition-target",
            className: "ui-effects-transfer"
        }, 300  );
    });
 $('#foo').hover(function() {
$('#bar').fadeIn(300);
        $(this).effect("transfer", {
            to: "#transition-target",
            className: "ui-effects-transfer"
        }, 300  );
    });
情话墙 2024-12-28 22:06:07

您可以使用 animate 执行 2 个或更多并行效果。

You can do 2 or more parallel fx using animate.

小猫一只 2024-12-28 22:06:07

两个并行运行两个动画,即同时使用 queue : false 并且不要将第二个动画放入第一个动画的回调函数中,如下所示:

$('#foo').hover(function() {
    $(this).effect("transfer", {
        to: "#transition-target",
        className: "ui-effects-transfer"
    }, { duration:300, queue: false});
    $('#bar').fadeIn({ duration: 300, queue: false});
});

Two run the two animations in parallel i.e. simultaneously use queue : false and don't put the second animation in the callback function of the first one like this:

$('#foo').hover(function() {
    $(this).effect("transfer", {
        to: "#transition-target",
        className: "ui-effects-transfer"
    }, { duration:300, queue: false});
    $('#bar').fadeIn({ duration: 300, queue: false});
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文