簡體   English   中英

如何在Dojo中停止動畫

[英]How to stop animation in Dojo

使用Dojo 1.9,我正在播放一些動畫,如下所示:

that.fadeOutActive = baseFx.fadeOut({ node: "active-container", duration: 1000, delay: 3000 });
that.fadeInInactive = baseFx.fadeIn({ node: "inactive-container", duration: 1000, delay: 3000 });
coreFx.combine([that.fadeOutActive, that.fadeInInactive]).play();

然后嘗試在事件中阻止它們,如下所示:

coreFx.combine([that.fadeOutActive, that.fadeInInactive]).stop();

問題是,這阻止了動畫的觸發(這是所需的行為),但是如果動畫已經開始,它並不會停止動畫(這是問題)。 如果可以的話,如何停止動畫?

編輯:原來我的問題不在我發布的代碼中,而是在檢測動畫是否在進行中。

dojo / fx :: combine()是一個輔助函數,可以獲取dojo / _base / fx :: Animation對象的列表並將其組合在一起,以便它們的效果都可以並行運行。 使用此功能,可以同時生成和執行影響多個節點的動畫。

您正在使用coreFx.combine同時fadeIn一個元素,並fadOut另一個元素。

代替創建新的組合動畫,您應該存儲對現有組合動畫的引用,然后使用該引用停止組合動畫:

that.fadeOutActive = baseFx.fadeOut({ node: "active-container", duration: 1000, delay: 3000 }).play();
that.fadeInInactive = baseFx.fadeIn({ node: "inactive-container", duration: 1000, delay: 3000 }).play();
that.combinedAnim = coreFx.combine([that.fadeOutActive, that.fadeInInactive]).play();

然后再:

that.combinedAnim.stop();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM