npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

inviewport

1.1.1

@juliangruber

npmHomeRepoSnykSocket
Downloads:10
$ npm install inviewport
DailyWeeklyMonthlyYearly

inviewport

Check if a dom element is fully contained in the viewport

Example

var inViewport = require('inviewport');

console.log(inViewport(document.querySelector('div')));

Installation

$ npm install inviewport

API

inViewport(el)

Return whether el is fully contained in the current viewport.

inViewport.watch(el, fn)

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.

License

MIT