YUI 动画在活动结束后?

发布于 2024-12-20 19:16:45 字数 243 浏览 0 评论 0原文

有没有办法在动画完成后触发事件? 这样做的理由是什么? 我对 YUI 库非常陌生,我迷路了..

我现在的情况是

    var anim = new Y.Anim({
        node: node,
        duration: 1.0,
        easing: Y.Easing.easeOut
    });

……等等

注意:这适用于 YUI2。

There is a way to trigger an event after an animation is done?
what's the cose for it?
I'm very new with YUI libraries and i'm getting lost..

my cose now is

    var anim = new Y.Anim({
        node: node,
        duration: 1.0,
        easing: Y.Easing.easeOut
    });

...etc

Note: This applies to YUI2.

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

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

发布评论

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

评论(3

萌无敌 2024-12-27 19:16:45

是的!类似于:

var myAnim = new YAHOO.util.Anim("yourId", {
   left: {from: 0, to:75}
}, 1);

myAnim.onComplete.subscribe(function() {
   alert('Done!');
});

请参阅 http://developer.yahoo.com/yui/examples/animation /index.html 了解更多示例。

Yup! Something like:

var myAnim = new YAHOO.util.Anim("yourId", {
   left: {from: 0, to:75}
}, 1);

myAnim.onComplete.subscribe(function() {
   alert('Done!');
});

See http://developer.yahoo.com/yui/examples/animation/index.html for more examples.

傻比既视感 2024-12-27 19:16:45

要在动画完成后执行某些操作,您只需监听“end”事件:

var anim = new Y.Anim({
    node: node,
    duration: 1.0,
    easing: Y.Easing.easeOut,
    on: {
        end: function (e) {
            // your stuff here
        }
    }
});

To do something after an animation is done, you just need to listen to the "end" event:

var anim = new Y.Anim({
    node: node,
    duration: 1.0,
    easing: Y.Easing.easeOut,
    on: {
        end: function (e) {
            // your stuff here
        }
    }
});
墟烟 2024-12-27 19:16:45

这个想法是,由于动画需要时间,因此您可能希望在动画完成时收到通知,以执行您可能需要的任何其他逻辑: 以下是该事件的一些用途:

  1. 动画完成后触发其他动画。这可以位于 UI 的同一元素或完全不同的部分。
  2. 从 DOM 中删除该元素。也许它是一个弹出窗口,一旦关闭(使用动画),DOM 中就不再需要
  3. 其他东西,例如用内容填充元素等。

The idea is, that since an animation takes time, you might want to be notified when the animation completes to perform any additional logic you might need: Here are a few uses for that event:

  1. Trigger additional animations once an animation completes. This can be on the same element or a completely different part of the UI.
  2. Remove the element from the DOM. Perhaps it was a popup-window, that once it is closed (with an animation), is no longer needed in the DOM
  3. Something other, like filling the element with content etc.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文