I am just trying to understand why the hell window.requestAnimationFrame is accepting the second parameter as an element, what is the reason behind that?

I am curious to know the underlying execution for this function....

有帮助吗?

解决方案

It's added so that when an element is out of view (because of scrolling for example), the animation is not run.

From 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?

More information about this issue can be found here.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top