<tfoot id='QfdHa'></tfoot>
  • <legend id='QfdHa'><style id='QfdHa'><dir id='QfdHa'><q id='QfdHa'></q></dir></style></legend>
  • <i id='QfdHa'><tr id='QfdHa'><dt id='QfdHa'><q id='QfdHa'><span id='QfdHa'><b id='QfdHa'><form id='QfdHa'><ins id='QfdHa'></ins><ul id='QfdHa'></ul><sub id='QfdHa'></sub></form><legend id='QfdHa'></legend><bdo id='QfdHa'><pre id='QfdHa'><center id='QfdHa'></center></pre></bdo></b><th id='QfdHa'></th></span></q></dt></tr></i><div id='QfdHa'><tfoot id='QfdHa'></tfoot><dl id='QfdHa'><fieldset id='QfdHa'></fieldset></dl></div>

        <bdo id='QfdHa'></bdo><ul id='QfdHa'></ul>

    1. <small id='QfdHa'></small><noframes id='QfdHa'>

        关于请求动画帧的问题

        时间:2023-09-05
      1. <legend id='QNLfN'><style id='QNLfN'><dir id='QNLfN'><q id='QNLfN'></q></dir></style></legend>
        • <bdo id='QNLfN'></bdo><ul id='QNLfN'></ul>
              <tbody id='QNLfN'></tbody>

            <small id='QNLfN'></small><noframes id='QNLfN'>

            <tfoot id='QNLfN'></tfoot>
          • <i id='QNLfN'><tr id='QNLfN'><dt id='QNLfN'><q id='QNLfN'><span id='QNLfN'><b id='QNLfN'><form id='QNLfN'><ins id='QNLfN'></ins><ul id='QNLfN'></ul><sub id='QNLfN'></sub></form><legend id='QNLfN'></legend><bdo id='QNLfN'><pre id='QNLfN'><center id='QNLfN'></center></pre></bdo></b><th id='QNLfN'></th></span></q></dt></tr></i><div id='QNLfN'><tfoot id='QNLfN'></tfoot><dl id='QNLfN'><fieldset id='QNLfN'></fieldset></dl></div>

                  本文介绍了关于请求动画帧的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试构建一个视差站点,它会在滚动站点时移动一些元素.但在阅读 Paul Irish 的这篇文章,以及 这个视频 说滚动监听器有点错误.我的问题是:

                  I'm trying to build a parallax site, which will move few elements while scrolling the site. But instead of using a scroll event listener I'm using requestAnimationFrame, after reading this post by Paul Irish, and this video which said that scroll listener is a bit buggy. My questions are:

                  1. 在 Chrome 中看起来很流畅,但在 Firefox 中闪烁很严重.我在这里做错了吗?
                  2. 我的代码实际上是否比使用普通的滚动事件监听器占用更多的资源?每次我使用这段代码时,我都能听到我的笔记本电脑风扇在燃烧.
                  1. It looks quite smooth in Chrome, but it's flickering badly in Firefox. Did I do something wrong here?
                  2. Does my code actually taking up more resources than using normal scroll event listener? I can hear my laptop fan blazing every time I'm playing with this code.

                  我的文件位于 http://www.socialbuzz.com.au/index.html,请滚动到页面底部以查看正在从 javascript 操作的元素.

                  My file is located at http://www.socialbuzz.com.au/index.html, and please scroll to the bottom of the page to see the element that's being manipulated from javascript.

                  推荐答案

                  你应该有一个滚动事件触发 requestAnimationFrame 循环.滚动事件本身不会触发 requestAnimationFrame.你应该有类似 var scrolling = true; 的东西.发生这种情况时,请运行您的 requestAnimationFrame 循环,该循环引用来自滚动事件的事件数据.完成后,您需要对滚动事件进行去抖动以关闭循环,这是一件苦差事,但结果是值得的.希望这可以帮助.

                  You should have a the scroll event trigger a requestAnimationFrame loop. Do not have requestAnimationFrame triggered by the scroll event itself. You should have something like a var scrolling = true; While this is happening run your requestAnimationFrame loop which references event data from the scroll event. You'll need to debounce the scroll event to turn to loop off once you are finished, it's a chore but the results are worth it. Hope this helps.

                  这篇关于关于请求动画帧的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:您在哪里存储您在 javascript Web 应用程序中使用的第三方 API ApiKey? 下一篇:如何将刷卡器中的分页项目符号更改为文本?

                  相关文章

                  <legend id='UwBRZ'><style id='UwBRZ'><dir id='UwBRZ'><q id='UwBRZ'></q></dir></style></legend>
                    <tfoot id='UwBRZ'></tfoot>

                    • <bdo id='UwBRZ'></bdo><ul id='UwBRZ'></ul>

                  1. <small id='UwBRZ'></small><noframes id='UwBRZ'>

                      <i id='UwBRZ'><tr id='UwBRZ'><dt id='UwBRZ'><q id='UwBRZ'><span id='UwBRZ'><b id='UwBRZ'><form id='UwBRZ'><ins id='UwBRZ'></ins><ul id='UwBRZ'></ul><sub id='UwBRZ'></sub></form><legend id='UwBRZ'></legend><bdo id='UwBRZ'><pre id='UwBRZ'><center id='UwBRZ'></center></pre></bdo></b><th id='UwBRZ'></th></span></q></dt></tr></i><div id='UwBRZ'><tfoot id='UwBRZ'></tfoot><dl id='UwBRZ'><fieldset id='UwBRZ'></fieldset></dl></div>