https://github.com/puemos/window-scroller
a window scroller impl vanila javascript
https://github.com/puemos/window-scroller
javascript scroller vanilajs
Last synced: about 1 year ago
JSON representation
a window scroller impl vanila javascript
- Host: GitHub
- URL: https://github.com/puemos/window-scroller
- Owner: puemos
- License: mit
- Created: 2017-01-27T13:49:03.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-02T07:49:01.000Z (almost 9 years ago)
- Last Synced: 2025-01-23T04:31:59.660Z (over 1 year ago)
- Topics: javascript, scroller, vanilajs
- Language: JavaScript
- Homepage:
- Size: 217 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# window-scroller
[](https://nodei.co/npm/window-scroller/)
## Credit:
@shunryu111
## Based on:
## install
```bash
npm install window-scroller --save
```
## usage
```javascript
import Scroller from 'window-scroller';
// OR
const Scroller = require('window-scroller');
// Position
Scroller.to(500).scroll()
Scroller.to(500).speed(700).scroll()
Scroller.to(500).easing('easeOutSine').scroll();
Scroller.to(500).speed(700).easing('easeInOutSine').scroll();
// Element in the DOM
const element = document.getElementById('rolling');
Scroller.to(element).scroll()
Scroller.to(element).speed(700).scroll()
Scroller.to(element).easing('easeInOutQuint').scroll();
Scroller.to(element).speed(700).easing('easeInOutQuint').scroll();
// Save the scroller and use whenever you need
const rollingScroller = Scroller.to(element).speed(700).easing('easeInOutQuint');
rollingScroller.scroll()
const topScroller = Scroller.to(0).speed(700).easing('easeOutSine');
topScroller.scroll()
```
## options
speed (Integer):
- 0 -> inf
easing (String):
- easeOutSine
- easeInOutSine
- easeInOutQuint
to (Integer | Element):
- DOM Element
- Integer