1.0.0 • Published 5 years ago

scroll-to-view v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

scroll-to-view

Example

Example

Install

npm

$ npm install scroll-to-view

CDN

<script src="https://unpkg.com/scroll-to-view/dist/scroll-to-view.js"></script>

Usage

scrollToView('#header', 300);

Attributes

namedesctypedefaultrequired
selectorelement selectorstring-✔️
durationanimate timenumber300-
callbackcallback functionfunction--

Callback

You can pass a callback or Promise that will be called when all scrolling has been completed.

// callback
scrollToView('#header', 300, () => console.log('done'));

// promise
scrollToView('#header', 300).then(() => console.log('done'))

Size

<= 1 KB