Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/visibility
A little browserify-able shim/wrapper for the Page Visibility API
https://github.com/hughsk/visibility
Last synced: 12 days ago
JSON representation
A little browserify-able shim/wrapper for the Page Visibility API
- Host: GitHub
- URL: https://github.com/hughsk/visibility
- Owner: hughsk
- License: mit
- Created: 2013-10-03T10:54:53.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-10T17:54:21.000Z (over 9 years ago)
- Last Synced: 2024-10-17T16:38:04.761Z (22 days ago)
- Language: JavaScript
- Size: 183 KB
- Stars: 14
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# visibility [![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #
A little [browserify](http://browserify.org)-able shim/wrapper for the
[Page Visibility API](http://www.html5rocks.com/en/tutorials/pagevisibility/intro/).## Usage ##
[![visibility](https://nodei.co/npm/visibility.png?mini=true)](https://nodei.co/npm/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](http://github.com/hughsk/visibility/blob/master/LICENSE.md) for details.