obzerv
A convenient wrapper around IntersectionObserver
for tracking element position relative to the viewport.
Install
$ npm i obzerv --save
API
.create(options)
Accepts a config object with callback
and offset
properties. Returns an observer instance with a track
function used to add nodes to the observer.
// example callback: lazy loading an imageconst callback = { // exit early if image not in viewport if !inview return // set src attribute of the image node // stop tracking image, because load attempt has been initiated } // create an observer instanceconst observer = obzerv // add all .box elements to the observerArray
License
MIT. © 2017 Michael Cavalea