【前端】回到顶部

2023-10-17 09:54:19 浏览数 (2)

代码语言:javascript复制
(function smoothscroll(){  
    var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;  
    if (currentScroll > 0) {  
         window.requestAnimationFrame(smoothscroll);  
         window.scrollTo (0,currentScroll - (currentScroll/5));  
    }  
})();  

0 人点赞