【发布时间】:2015-03-14 23:16:45
【问题描述】:
我用requestAnimationFrame(animate);函数改变文字颜色:
requestAnimationFrame(animate);
function animate(time){
... // change text color here
if (offset_s < offset_e) {requestAnimationFrame(animate);}
}
offset_s 和offset_s 指示颜色更改文本的开始和结束位置。在某些情况下,动画应该持续 2 秒,但在顺序情况下 - 持续 5 秒,但 offset_e - offset_s 在这两种情况下可能相同。我该怎么做才能根据给定的时间(以秒/毫秒为单位)控制动画的速度?
【问题讨论】:
-
如果你只是改变颜色,你可以使用 css 动画,用它来控制时间会更容易
标签: javascript animation canvas html5-canvas requestanimationframe