Answers for "scroll to top in javascript duration"

1

scroll to top in javascript duration

scrollToPageTopWithSlowAniemation(){ 
  var scrollToTop = window.setInterval(function() {
    var pos = window.pageYOffset;
    if ( pos > 0 ) {
      window.scrollTo( 0, pos - 20 ); // how far to scroll on each step
    } else {
      window.clearInterval( scrollToPageTopWithSlowAniemation );
    }
  }, 16);//16 is the duration
}

just copy and call this scrollToPageTopWithSlowAniemation();
Posted by: Guest on February-26-2021
1

scroll to top in javascript duration

scrollToPageTopWithSlowAniemation(){ 
  var scrollToTop = window.setInterval(function() {
    var pos = window.pageYOffset;
    if ( pos > 0 ) {
      window.scrollTo( 0, pos - 20 ); // how far to scroll on each step
    } else {
      window.clearInterval( scrollToPageTopWithSlowAniemation );
    }
  }, 16);//16 is the duration
}

just copy and call this scrollToPageTopWithSlowAniemation();
Posted by: Guest on February-26-2021

Code answers related to "scroll to top in javascript duration"

Code answers related to "Javascript"

Browse Popular Code Answers by Language