我需要在dom元素上的动画结束后执行方法。 目前我使用下面的代码没有成功。dojo/_base/fx支持承诺吗?
我想知道如果道场,支持承诺的动画,如果没有,我想知道我能以哪种方式工作。
fx.fadeOut({ node: 'target'}).play().then(function() {
// do smt here
}.bind(this));
我需要在dom元素上的动画结束后执行方法。 目前我使用下面的代码没有成功。dojo/_base/fx支持承诺吗?
我想知道如果道场,支持承诺的动画,如果没有,我想知道我能以哪种方式工作。
fx.fadeOut({ node: 'target'}).play().then(function() {
// do smt here
}.bind(this));
是的,你可以使用FadeOut
功能的注册回调。
的fadeOut
(dojo/_base/fx
函数返回一个annimation实例) 提供5个registred回调函数:
你的情况,你需要做的时候动画完成一些动作已经过时了在FadOut
参数的onEnd
功能,它应该看起来像:
fx.fadeOut({
node:"target",
onEnd: function(){
// Some stuff at the end of the animation.
}
}).play();
你也可以用上面的回调为ARGS。
我能解决使用'dojo/on'
和订阅到End
事件上fx.fadeOut()
这个问题。我仍然很有兴趣了解是否有更好的方法来达到同样的结果。
var anim = fx.fadeOut({ node: 'target'}).play();
on(anim, "End", function() {
// dom smt here
}.bind(this));