我只是想了解为什么 window.requestAnimationFrame
接受第二个参数作为元素,这背后的原因是什么?
我很想知道这个函数的底层执行....
最佳答案
添加它是为了当元素不在 View 中时(例如由于滚动),动画不会运行。
来自 the specs :
Editorial note
ISSUE-4 Do we want to allow an Element to be passed to requestAnimationFrame, so that animations affecting the given element are throttled or paused when scrolled out of view?
关于这个问题的更多信息可以found here .
关于javascript - 为什么 requestAnimationFrame 函数接受一个元素作为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7487691/