react-component / tween-one

Animate One React Element
https://tween-one.vercel.app/
MIT License
380 stars 30 forks source link

不在当前窗口时不进行动画 #45

Closed jljsj33 closed 5 years ago

jljsj33 commented 5 years ago

https://github.com/react-component/tween-one/blob/58e6dd3972c56d96e5832b179d20e6a72c4d0ab9/src/ticker.js#L41-L56

不在当前窗口时, raf 停止工作,但时间在变动,所以在回到窗口后会有一次跳动,还有相关重复播放的 bug。

解决方案: 在离开窗口时记录当前时间,回到窗口后把当前的时间与记录的时间相减,结下来在 getTime 里减去两值的相差。。

记录一下,没时间整。。