in-scroll-view
Keep track of whether an element is in view or out of view.
To get started
CommonJS
$ npm install in-scroll-view
var VIEW = ;
Browser Global
Initialize
// these options are the default options so this wouldn't be necessary.var options = percentInView: 075 attr: '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'.
Additional methods
// 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;
License
MIT © The C2 Group