document-visibility
v1.0.1
Published
Handle changes to browser document visibility
Downloads
732
Maintainers
Readme
document-visibility
Handle changes to browser document visibility using the Page Visibility API
Install
$ npm install --save document-visibility
Usage
var Visibility = require('document-visibility')
var visibility = Visibility()
visibility.visible()
//=> true/false
visibility.onChange(function (visible) {
//=> true/false
})
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