Node's Perpetuum Mobile

    document-visibility

    1.0.1 • Public • Published

    document-visibility Build Status

    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

    Install

    npm i document-visibility

    DownloadsWeekly Downloads

    27

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • bendrucker