做网站|网站建设,就上易助科技网

前端技术文档及相关资料下载

关于前端html、css、js等技术上的各种疑难棘手问题的解决方案探讨及相关资料下载!

JS平滑滚动插件SmoothScroll
来源:易助科技网浏览量:5收藏

简介

smoothscroll.js 是一款纯 JS 页面平滑滚动插件。该js页面平滑滚动插件的特点是页面滚动的行为被作为 window 对象的扩展,用户可以通过 window 对象直接调用平滑滚动的方法。


API方法

window.scroll or window.scrollTo
window.scroll({ top: 2500, left: 0, behavior: 'smooth' });
window.scrollBy
window.scrollBy({ top: 100, left: 0, behavior: 'smooth' });
window.scrollBy
window.scrollBy({ top: -100, left: 0, behavior: 'smooth' });
element.scrollIntoView
document.querySelector('.hello').scrollIntoView({ behavior: 'smooth' });
element.scroll or element.scrollTo
element.scroll({ top: 0, left: 0, behavior: 'smooth' });
element.scrollBy
element.scrollBy({ top: 100, left: 0, behavior: 'smooth' });
Scroll to top
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
or

document.querySelector('header').scrollIntoView({ behavior: 'smooth' });


相关链接

官网地址 :http://iamdustan.com/smoothscroll/

GitHub 地址 :https://github.com/iamdustan/smoothscroll