scroll-to
Imperatively smooth scroll to the given y-coordinates.
Installation
$ npm install @f/scroll-to
Usage
var scrollTo = require('@f/scroll-to')
// scroll to y-coordinates `100` with a duration of `500` and a
// custom easing function
scrollTo(100, 500, easeOutQuint)
Example
To run the example showed in the gif above, run:
$ npm i && npm run example
API
scrollTo(y, duration, easing, offset)
-
y
- Position to move to. -
duration
- Duration of the scrolling animation. -
easing
- Custom easing function. Defaults to a linear function (t => t
). -
offset
- Scroll offset position. Defaults towindow.scrollY
.
License
MIT