scroll
A function that animates an element’s scrollTop or scrollLeft position.
install
$ npm install scroll
use
var scroll = require('scroll')
var page = require('scroll-doc')()
var ease = require('ease-component')
scroll.left(page, 200)
scroll.top(page, 200, function (err, scrollTop) {
console.log(err)
console.log(scrollTop)
})
scroll.left(page, 200, { ease: ease.inBounce })
scroll.left(page, 200, { duration: 1000 }, function (err, scrollLeft) {
})
var options = { duration: 1000 }
var cancel = scroll.top(page, 200, options, function (err, scrollTop) {
console.log(err.message)
page.removeEventListener('wheel', cancel)
})
page.addEventListener('wheel', cancel)
Note: The default easing is inOutSine
from component/ease.
compression | size |
---|
scroll.js | 2.86 kB |
scroll.min.js | 1.71 kB |
scroll.min.js.gz | 764 B |
obey
MIT