简体   繁体   English

为什么requestAnimationFrame函数接受一个元素作为参数?

[英]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? 我只是想了解为什么地狱window.requestAnimationFrame接受第二个参数作为一个元素,背后的原因是什么?

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? ISSUE-4我们是否要允许将一个Element传递给requestAnimationFrame,以便在滚出视图时影响给定元素的动画会受到限制或暂停?

More information about this issue can be found here . 有关此问题的更多信息,请访问此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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