我对Dojo的世界很陌生,所以这可能是一件愚蠢的事情,让我很难过。如何在组合动画结束时执行动作?
我有以下代码(剥离不相关的东西):
define(["dojo/_base/declare", "dojo/fx", "dojo/on"],
function (declare, fx, on) {
return declare(null, {
executeTransition: function (continuation) {
var animation = fx.combine([
fx.slideTo({
duration: 1200,
node: this.node1, // node1 will be a valid node at the moment of execution
left: -this.node1.offsetWidth
}),
fx.slideTo({
duration: 1200,
node: this.node2, // node2 will be a valid node at the moment of execution
left: 0
})
]);
on(animation, "End", continuation);
animation.play();
}
});
}
);
当执行我的代码,因为它是在on
线路出现故障说Uncaught Error: Target must be an event emitter
。但作为一个动画,它应该是事件发射器吗?
一些背景研究,我也试图解决我的问题:的fx.combine
的reference guide to dojo.fx治疗结果与任何其他动画。 API reference for dojo.fx只声明它返回一个实例。
无论如何,Dojo 1.8 animation tutorial与我试图执行的例子非常相似,只是它稍后将fx.combine的结果包裹在fx.chain中(我不需要 - 或者我会这样做)。
所以,我的问题是:使用Dojo 1.8,如何在并行运行两个动画并在完成时执行一些代码?
非常感谢。我的第一个方法是直接使用这个方法,但那不起作用。该动画对象不公开onEnd方法。但是,使用dojo/aspect确实有效(为什么,如果方法不在那里?)。 – Alpha
不确定为什么你不能直接使用onEnd()方法;它似乎为我工作得很好。这可能与方法创建时有关。 Dojo/aspect可能会捕获这个,但它不可用,那么你尝试在dojo/aspect之外使用它。dojo/on的原因实际上是一个错误,所以我会密切关注事情,现在的任何解决方法都可能会在问题得到解决后再解决。也许,尝试在尝试中包装一个dojo/on子句... catch catchback到你的dojo/aspect代码。当问题解决后,你会使用dojo/on。 –