ease-scroll-to

Scroll web in an ease, fast and smooth way.

Usage no npm install needed!

<script type="module">
  import easeScrollTo from 'https://cdn.skypack.dev/ease-scroll-to';
</script>

README

INSTALL 安装

# with npm
npm install ease-scroll-to

# with yarn
yarn add ease-scroll-to

QUICK START 快速开始

1、The basic usage to scroll to the top.(不传参数默认滚动到页面顶部)

import easeScrollTo from "ease-scroll-to"

button.onclick = () => easeScrollTo().then(options => {
    console.log(options)
})

2、Scroll to the target.(传入参数为数值)

// equal to window.scrollTo({ top: 200 })
button.onclick = () => easeScrollTo(200)

3、These are the available config options.(传入配置对象)

const options = {
    top: 0, // The target scrollTop(px).
    duration: 300, // The animation duration(ms).
    target: window, // The scroll container, you can pass a HTMLElement.
    type: 'ease' // It can be 'linear' too.
}
button.onclick = () => easeScrollTo(options)