我對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。 –