简体   繁体   中英

Why does requestAnimationFrame function accept an element as an argument?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM