viewport-events
v1.0.2
Published
Enable viewport events for DOM-elements: enteredView, leftView
Downloads
1
Readme
Viewport events
Enable viewport events for HTML elements: enteredView
, leftView
.
Usage
$ 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);
API
vp.enable(selector)
Enable viewport events for an Element, NodeList or selector. If no selector specified, '*'
is used.
vp.disable(selector)
Disable viewport events for previously registered selector. If no selector specified, all viewport events are unbound.
vp.enteredViewCallbackName
Callback name used for entering viewport event. enteredView
is used by default.
vp.leftViewCallbackName
Callback name used for leaving viewport event. leftView
is used by default.