【发布时间】:2015-12-21 12:27:23
【问题描述】:
我正在构建一个带有 css 动画的游戏。
我有这个用于移动动画的 CSS 规则:
.animate {
animation: play-move 1s steps(10) infinite;
}
我每半秒更新一次状态,因此状态更改为:
- 状态:
[0, 1, 0]查看:<div/><div class="animate"/><div /> - 状态:
[0, 0, 1]查看:<div/><div/><div class="animate">
问题是随着 dom 的变化,css 动画重置,所以我看不到完整的动画。
查看反应版本:
http://jsfiddle.net/CGmCe/12998/
但是,如果您反转移动方向,动画不会重置。
秘银版本: http://jsfiddle.net/CGmCe/12982/
jquery: http://jsfiddle.net/CGmCe/12968/
【问题讨论】:
-
你能做这个吗?
-
@ParthTrivedi 我做到了。
-
不,它不播放完整的动画,它只播放一半,我需要动画在它移动的过程中无缝地继续。 @ParthTrivedi。 PS:把
updateDuration变量改成1000可以看到完整的动画播放。 -
你能隐藏/显示你的动画 Div 以避免重置吗?
-
为什么不使用
translate动画,而不是更新div的类属性?
标签: javascript css html reactjs