javascript 顺畅滚动

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 顺畅滚动相关的知识,希望对你有一定的参考价值。


$(function () {
  //Smooth Scroll from https://css-tricks.com/snippets/jquery/smooth-scrolling/
  //Updated to account for fixed header height
  // Select all links with hashes
    $("a[href*='#']:not([href='#'])").click(function () {
      if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
        var target = $(this.hash);
        var headerHeight = $("header").height();
        var scrollToPosition = $(target).offset().top - headerHeight;
        target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
        if (target.length) {
          $('html,body').animate({
            scrollTop: scrollToPosition}, 800);
          return false;
        }
      }
    });

以上是关于javascript 顺畅滚动的主要内容,如果未能解决你的问题,请参考以下文章

javascript 顺畅滚动

滚动完成前Recyclerview滚动不顺畅

iCarousel 滚动不顺畅

ScrollView 内的 Recyclerview 滚动不顺畅

TextView 滚动不顺畅

NestedScrollview 内的 RecyclerView 滚动不顺畅