Enable viewport events for HTML elements: enteredView
, leftView
.
$ npm install viewport-events
var vpEvents = require('viewport-events');
//enable viewport events for all elements on the page
vpEvents.enable();
$('.my-element').on('leftView', function(){});
$('.my-other-element').on('enteredView', function(){});
//Disable all viewport events
vpEvents.disable();
//Enable viewport events for a Node/NodeList
vpEvents.enable(element);
element.addEventListener('enteredView', function(){});
element.addEventListener('leftView', function(){});
//Disable viewport events for the previously added element/selector
vpEvents.disable(element);
Enable viewport events for an Element, NodeList or selector. If no selector specified, '*'
is used.
Disable viewport events for previously registered selector. If no selector specified, all viewport events are unbound.
Callback name used for entering viewport event. enteredView
is used by default.
Callback name used for leaving viewport event. leftView
is used by default.