[英]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.