1.0.3 • Published 8 years ago

scroll-lazy v1.0.3

Weekly downloads
11
License
MIT
Repository
github
Last release
8 years ago

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

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago