scroll-lazy
v1.0.3
Published
Event emitter for lazy scrolling.
Downloads
10
Maintainers
Readme
lazy.js
Install:
npm install scroll-lazy
Event emitter for lazy scrolling.
// Create
var Lazy = require('scroll-lazy')
var lazy = Lazy
.on(function(next) {
// ...do something
next() // lazy checker resume on next
})
.watch()
// stop lazy
lazy.off()
With option.
// this is default option setting
lazy.watch({
check:function(callback) {
callback(null,this.body()-this.container() < this.scroll()+this.threshold())
},
threshold:function() {
return 10
},
scroll:function() {
return document.body.scrollTop
},
body:function() {
var height = document.body.offsetHeight
var style = getComputedStyle(document.body)
height += parseInt(style.marginTop) + parseInt(style.marginBottom)
return height
},
container:function() {
return window.innerHeight
},
})
Option
threshold
default:10
container
default:window.innerHeight
scroll
default:document.body.scrollTop
body
default:document.body.outerHeight
License
MIT