slick-scroll
Demos
Credit:
@shunryu111 http://stackoverflow.com/users/2630316/shunryu111
Based on:
http://stackoverflow.com/a/26798337/5068410
install
npm install slick-scroll --save
usage
;// ORconst Scroller = ; // windowconst windowScroller = speed: 1000 // Containerconst container = document; const containerScroller = element: container speed: 1000 myScrollermyScrollermyScroller;myScroller; // Element in the DOMmyScrollermyScrollermyScroller;myScroller; // Save the scroller and use whenever you needconst scrollToTop = myScroller;scrollToTop const menu = document;const scrollToMenu = myScroller;scrollToMenu
object
Options : Kind: global typedef Properties
Name | Type | Default |
---|---|---|
element | Element |
window |
speed | number |
500 |
easing | string |
"'easeOutSine'" |
Scroller
- Scroller
- instance
- .setSpeed(speed) ⇒
this
- .setEasing(easing) ⇒
this
- .to(to) ⇒
this
- .calcTime()
- .getNodeTop(node) ⇒
number
- .scroll([cb])
- .setSpeed(speed) ⇒
- static
- instance
this
scroller.setSpeed(speed) ⇒ Sets the scroll speed
Kind: instance method of Scroller
Param | Type |
---|---|
speed | number |
this
scroller.setEasing(easing) ⇒ Sets the scroll easing function
Kind: instance method of Scroller
Param | Type |
---|---|
easing | string |
this
scroller.to(to) ⇒ Sets the scroll to
Kind: instance method of Scroller
Param | Type |
---|---|
to | Element | number |
scroller.scroll([onSuccess], [onFailure])
Scroll
Kind: instance method of Scroller
Param | Type | Default | Description |
---|---|---|---|
[onSuccess] | function |
() => {} |
callback function when finish to scroll |
[onFailure] | function |
() => {} |
callback function when failed to scroll |
Scroller.Scroller
Kind: static class of Scroller
new Scroller(options)
Creates an instance of Scroller.
Param | Type |
---|---|
options | Options |