Check if a dom element is fully contained in the viewport
var inViewport = require('inviewport');
console.log(inViewport(document.querySelector('div')));
$ npm install inviewport
Return whether el
is fully contained in the current viewport.
Call fn
immediately and whenever it moves in or out of the viewport, with one boolean argument denoting visibility.
Returns an unwatch()
function, which you can call to stop listening for DOM events.
MIT