document-visibility
Handle changes to browser document visibility using the Page Visibility API
Install
$ npm install --save document-visibility
Usage
var Visibility = var visibility = visibility//=> true/false visibility
API
visibility.visible()
-> boolean
Returns the visibility of the document. If the browser does not support the visibility API, this will always be true
.
visibility.onChange(fn)
-> function
Returns an unlisten function.
fn
Required
Type: function
Arguments: visible
A function to call when the page visibility changes.
License
MIT © Ben Drucker