requestAnimationFrame和定时器的区别

版权声明:内容多为自言自语,请自行判断有无价值。 https://blog.csdn.net/weixin_41702247/article/details/84553069

旧式定时器的问题:执行时机不可控(js异步执行队列机制、软硬件实现方式区别)

rAf:页面重绘时立刻执行回调函数,不需要人为设置执行间隔,避免了过度绘制的问题

参考:

https://www.zhangxinxu.com/wordpress/2013/09/css3-animation-requestanimationframe-tween-%E5%8A%A8%E7%94%BB%E7%AE%97%E6%B3%95/

http://taobaofed.org/blog/2017/03/02/thinking-in-request-animation-frame/

猜你喜欢

转载自blog.csdn.net/weixin_41702247/article/details/84553069