Skip to content

A little browserify-able shim/wrapper for the Page Visibility API

License

Notifications You must be signed in to change notification settings

hughsk/visibility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

visibility experimental

A little browserify-able shim/wrapper for the Page Visibility API.

Usage

visibility

watcher = require('visibility')()

Creates a new EventEmitter that fires specific events when the pages's visibility status has changed.

watcher.hidden()

Returns true if the browser window is not currently visible. If the browser does not support the Page Visibility API, this method will always return false.

watcher.visible()

Returns true if the browser window is currently visible. If the browser does not support the Page Visibility API, this method will always return true.

watcher.on('change', handler(visible))

Called whenever the page's visibility is toggled, passing visible as a boolean.

watcher.on('show', handler)

Called only when the page becomes visible again.

watcher.on('hide', handler)

Called only when the page is hidden.

License

MIT. See LICENSE.md for details.

About

A little browserify-able shim/wrapper for the Page Visibility API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published