返回
创建于
状态
公开
语法介绍
语法如下:
不同点
requestIdleCallback
Due to the fact at which point in the frame life cyclerICcallbacks are called you should not alter the DOM (userAFfor this).requestAnimationFrame
rAFgives you the point inside the frame life cycle right before the browser wants to calculate the new style and layout of the document. This is why it is perfect to use for animations. First it won't be called more often or less often than the browser calculates layout (right frequency). Second it is called right before the browser does calculate the layout (right timing). In fact usingrAFfor any layout changes (DOM or CSSOM changes) makes a lot of sense.rAFis synced with the V-SYNC as any other layout rendering related stuff in the browser.
https://medium.com/@paul_irish/requestanimationframe-scheduling-for-nerds-9c57f7438ef4
React Scheduler
https://github.com/facebook/react/issues/21662
No, it fired too late and we'd waste CPU time. It's really important for our use case that we utilize CPU to full extent rather than only after some idle period. So instead we rewrote to have our own loop that yields every 5ms.