README
ease-scroll-to
Install
# with npm
npm install ease-scroll-to
# with yarn
yarn add ease-scroll-to
Quick Start
javascript
import easeScrollTo from "ease-scroll-to"
window.onclick = () => {
easeScrollTo().then(options => {
console.log(options)
})
}
typescript
import easeScrollTo from "ease-scroll-to"
const app = document.getElementById('app')
window.onclick = () => {
easeScrollTo({
target: app!,
top: 0,
duration: 300,
type: 'ease',
}).then(options => {
console.log(options)
})
}
Options
This function accepts a param which is default 0 and return a Promise
which returns the options
when resolved.
If the param is a number, it will assign to options.top
.
Otherwise, the param should be an object and will assign to options
.
The default options
is:
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' // Types: ease, linear
}