简体   繁体   English

为什么我的页面顶部按钮在我的 API 应用程序上滚动到顶部然后返回时会卡顿/滞后/粘滞,但在网页上却正常运行?

[英]Why does my top of page button stutter/lag/stick when I scroll to top and then back down on my API app but acts normal on webpages?

So I have an API that I added a top of page button to.所以我有一个 API,我添加了一个页面顶部按钮。 The button works fine on mobile and desktop on 2 webpages I built but for my API apps (this one especially) it lags/stutters/sticks when I get down to mobile screen sizes.该按钮在我构建的 2 个网页上的移动和桌面上运行良好,但对于我的 API 应用程序(尤其是这个),当我使用移动屏幕尺寸时,它会滞后/卡顿/卡住。 Take a look at my screen shot and here is the code:看看我的屏幕截图,这里是代码:

      <!--Top of Page Button-->
    <div  class="top_link_position">
      <a  class="back-to-top" href="#page_top" title="Top">
      <button class="top_btn">
       <i class="fas fa-arrow-up fa-3x"></i>

       
      </button>
      </a>
  </div>

    .top_link_position {
  display: block;
position: fixed;
  bottom: 4%;
  right: 3%;
  z-index: 600;
}


.top_btn {
    border: 1.5px solid white;
    background: #db0606;
    padding: .5rem .5rem;
    color: white;
    font-weight: bolder;
    text-transform: uppercase;
}

$(document).ready(function () {
   $(window).scroll(function () {
      if ($(this).scrollTop() > 100) {
         $('.back-to-top').fadeIn();
      } else {
         $('.back-to-top').fadeOut();
      }
   });

   $('.back-to-top').click(function () {
      $("html, body").animate({
         scrollTop: 0
      }, 100);
      return false;
   });

});

当我滚动到顶部并返回时,它会执行此操作

The only solution I found was getting another button and code from a different source.我找到的唯一解决方案是从不同来源获取另一个按钮和代码。 A lot of these you find on google don't seem to work.你在谷歌上找到的很多这些似乎都不起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么向下滚动时不重新加载数据,而在无限滚动中返回页面顶部时为什么不重新加载数据? - Why do not I reload the data when I scroll down and do it when I go back to the top of the page in my infinite scroll? 为什么当我在页面顶部滚动并单击附加表格的链接时,它会向下滚动 - Why when i scroll top my page and click link which append a form it scroll me down 为什么我的 header 没有粘在我的页面顶部 - Why does my header not stick to the top of my page 我希望页面向下滚动,当我的 cursor 接近页面顶部或底部时自动顶部 - I want the page to scroll down, top automatically when my cursor is near the top or bottom of the page 如何获得锚链接,使其在向下滚动时像在其上一样平滑地向上滚动? - How can I get my anchor link to scroll smoothly back up top like it does when it goes down? 当我按下影响效果的按钮时,如何做向下滑动效果以不使我的网页回到顶部? - How can I do the slide down effect to not bring my web page back to top when I press the button that actions the effect? 尝试让我的导航栏停留在页面顶部并滚动 - Trying to get my navbar to stick to the top of the page and scroll with it 为什么我的“返回首页”按钮在Firefox上失败? - Why does my “Back to Top” button fail on Firefox? 滚动时,为什么我的网站在Chrome中显示滞后? - Why does my website show lag in Chrome when I scroll? 我在网站上有一个返回页面顶部的按钮,如何动画化返回顶部的动画? - I have a return to top of the page button in my website, how can I animate scrolling back to the top?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM