https://github.com/zhuowenli/scroll-to-view
https://github.com/zhuowenli/scroll-to-view
javascript javascript-only npm-package scroll-into-view
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zhuowenli/scroll-to-view
- Owner: zhuowenli
- License: mit
- Created: 2019-08-17T03:44:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-17T08:46:22.000Z (almost 6 years ago)
- Last Synced: 2025-01-08T11:34:20.648Z (4 months ago)
- Topics: javascript, javascript-only, npm-package, scroll-into-view
- Language: HTML
- Homepage: http://www.zhuowenli.com/scroll-to-view/
- Size: 1.11 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scroll-to-view
## Example
[Example](http://www.zhuowenli.com/scroll-to-view/)
## Install
### npm
```
$ npm install scroll-to-view
```### CDN
```html```
## Usage
```js
scrollToView('#header', 300);
```### Attributes
| name | desc | type | default | required |
|------------- |----------------- |---------- |-------- | -------- |
| selector | element selector | string | - | ✔️ |
| duration | animate time | number | 300 | - |
| callback | callback function| function | - | - |### Callback
You can pass a callback or `Promise` that will be called when all scrolling has been completed.```js
// callback
scrollToView('#header', 300, () => console.log('done'));// promise
scrollToView('#header', 300).then(() => console.log('done'))
```## Size
<= 1 KB