我正在建立一个使用requestAnimationFrame进行视差滚动的网站.有多个部分,每个部分都具有全尺寸的背景图像和一些中间和前景图像.我已经设法通过requestAnimationFrame相对顺利地得到这个动画,但动画中还是偶尔发生抖动.
通过在Frame模式下查看Chrome的时间轴,我可以看到导致“jank”的进程被标记为“Image Decode”.此外,一旦动画完成一次,就不会再发生.
解决方法
该问题可能与从视频中滚动的图像有关.
从http://creativejs.com/resources/requestanimationframe/
It has also been hinted that browsers could choose to optimize
performace of requestAnimationFrame based on load,element visibility
(being scrolled out of view) and battery status.
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?
确保您没有为每个onscroll事件启动requestAnimationFrame循环,因为这可能会导致问题.这在这个单独的帖子中有详细描述