scroll to top in javascript duration code example
Example: 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();