jQuery为什么不使用requestAnimationFrame?

编程入门 行业动态 更新时间:2024-10-25 08:23:23
本文介绍了jQuery为什么不使用requestAnimationFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

某些浏览器支持requestAnimationFrame,那么为什么不使用它呢?毕竟,自Google Chrome 10起,它一直得到支持.尽管如此,jQuery 似乎并未使用.我找到了有关它的错误报告,但是没有给出真正的解释吗?我确信jQuery的人有他们的理由.

Some browsers support requestAnimationFrame, so why not use it? After all, it's been supported since Google Chrome 10. Despite that, jQuery does not seem to be using it. I've found a bug report about it, but no real explanation was given? I'm sure the jQuery people have their reasons, though.

他们为什么不使用这个很棒的API?

Why wouldn't they use this awesome API?

推荐答案

在机票#9381 中,您可以了解他们的原因一段时间后停止使用requestionAnimationFrame.

In ticket #9381 you can read why they stopped using requestionAnimationFrame after some time.

总而言之,问题在于当窗口没有焦点时动画没有运行(浏览器试图减少CPU负载),如果隐藏了窗口则可以,但是如果可见则不可以.重点.此外,动画队列堆积起来,在窗口重新获得焦点之后,事情变得疯狂起来.这将需要对代码进行难看的更改和/或更改人们向动画队列中添加内容的方式.因此决定取消支持,直到有更好的方法可以做到这一点.

To summarize, problems were that animations didn't run (browsers try to reduce CPU load) when window didn't have focus, which is OK if the window is hidden, but not if it is visible, just out of the focus. Furthermore, animation queues piled up and after window regained focus, things went berserk. This would require ugly changes in the code and/or changes how people add things to the animation queue. So it was decided that support is removed until there is some better way to do this.

更多推荐

jQuery为什么不使用requestAnimationFrame?

本文发布于:2023-11-25 03:07:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628070.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:jQuery   requestAnimationFrame

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!