viewport
horizontal viewport based router
install
$ npm install bloody-viewport
require
var viewport =
api
viewport() > v
creates a viewport router
v
defines a viewport instance
v.use(options) > v
options
range {Array}
array containing the viewport boundaries (eg. [0, 310]
means 0 <= viewport <= 310
).
on {Function}
callback when arriving within the given viewport boundaries.
off {Function}
callback when leaving the given viewport boundaries.
v.init() > v
inits v
(to use after having your ranges configured),
executes the right callbacks and starts listening to window
resizes.
v.update(viewportWidth {Number}) > v
Executes the callbacks matching viewportWidth
.
v.destroy()
Removes all ranges and stops listening to resizes.
examples
var viewport = var router = router