Keep track of whether an element is in view or out of view.
To get started
$ npm install in-scroll-view
var VIEW = ;
// these options are the default options so this wouldn't be necessary.var options =percentInView: 075attr: 'data-view'lock: '' // 'in' or 'out';// Add itemsVIEW; // first parameter is anything jQuery accepts
Now when 75% of a "section" is in view, the attribute
data-view will change from 'out' to 'in'.
If lock is set to 'in', an item is automatically removed when the status changes to 'in'.
// re-measure the window and items positionVIEW;// re-calculate the views based on scrollTop// (this is automatically called with `measure`)VIEW;// unbind the events attached to the windowVIEW;// re-bind the events to the windowVIEW;// listen to changes in an items statusVIEW;// remove all itemsVIEW;
MIT © The C2 Group