有些浏览器支持requestAnimationFrame
,为什么不使用它呢?毕竟,已经是supported since Google Chrome 10岁了.尽管如此,jQuery does not seem to be using it.我找到了关于它的bug report,但是没有给出真正的解释?不过,我相信jQuery人员有他们的理由.
Why wouldn't they use this awesome API?
有些浏览器支持requestAnimationFrame
,为什么不使用它呢?毕竟,已经是supported since Google Chrome 10岁了.尽管如此,jQuery does not seem to be using it.我找到了关于它的bug report,但是没有给出真正的解释?不过,我相信jQuery人员有他们的理由.
Why wouldn't they use this awesome API?
In ticket #9381 you can read why they stopped using requestionAnimationFrame
after some time.
总而言之,问题在于当窗口没有焦点时,动画没有运行(浏览器试图减少CPU负载),如果窗口是隐藏的,这是可以的,但如果它是可见的,只是没有焦点,就不会运行.此外,动画队列堆积如山,在窗口重新聚焦后,事情变得疯狂.这将需要对代码进行丑陋的更改和/或更改人们向动画队列添加内容的方式.所以决定在找到更好的方法之前取消支持.