jQuery为什么不使用requestAnimationFrame? [英] Why doesn't jQuery use requestAnimationFrame?

查看:227
本文介绍了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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆