我写了一个React应用程序,使用CSS转换。但是这些转换在某些组件中无法正常工作。在my app中,只有向上移动的组件运行良好,向下移动的组件没有动画即时移动。 (我想他们两个动画移动)反应CSS转换不能正常工作
这里是我以前在那里的CSS:
div.canvas {
position: absolute;
top: 90px;
left: 60px;
width: 640px;
height: 480px;
border: 1px solid #999;
background: white;
}
div.canvas-rect {
position: relative;
margin-left: 20px;
margin-top: 10px;
height: 20px;
background: green;
transition: all 1s linear;
-moz-transition: all 1s linear; /* Firefox 4 */
-webkit-transition: all 1s linear; /* Safari 和 Chrome */
-o-transition: all 1s linear; /* Opera */
}
更新:
我还内置了codepen.io project显示的问题。它有这个演示项目的完整代码。
我试图日志条目添加到componentDidUpdate
,componentDidMount
和componentWillUnmount
方法来显示是否这些组件是重新创建或更新,这表明它们都更新(不重新创建,或删除)每秒。
我们不能调试仅2 CSS规则,你必须张贴工作代码片段重现问题 – LGSon
@LGSon对不起,我已经建立了一个codepen.io项目将尽快更新问题。 – cmal
通过简单地交换一些顶部值,它们也开始向下生成动画。我想你需要检查这些值如何切换项目。 https://codepen.io/anon/pen/ZJazQa ...还要注意,未加前缀的属性应该总是在CSS – LGSon