An angularjs interface of page visibility API
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist
js
spec
src
.gitignore
.vimrc
Gruntfile.coffee
README.md
bower.json
karma.conf.coffee
package.json
todos.md

README.md

Angular Page Visibility: a Page Visibility API interface for Angular

angular-page-visibility is a tiny lib which integrate Page Visibility API with Angular.

It is exposed as a scope, which $broadcast-s pageFocused and pageBlurred when page is focused / blurred. For old browsers not supporting page visibility API, it ignores it silently.

Usage

To use angular-page-visibility, just inject it, then listen to the events.

angular.module('app')
       .controller('MyController', function($scope, $pageVisibility) {
         $pageVisibility.$on('pageFocused', function(){
           // page is focused
         });

         $pageVisibility.$on('pageBlurred', function(){
           // page is blurred
         });
       });

Installation

  1. include script: script can be included via bower or downloading directly
  • via bower: $ bower install angular-page-visibility

  • download directly

<script src="https://raw.githubusercontent.com/mz026/angular_page_visibility/v0.0.3/dist/page_visibility.min.js" type="text/javascript"></script>
  1. include the module:
angular.app('myApp', [ 'angular-page-visibility' ])

Testing

to test angular-page-visibility, grunt, karma are needed.

  1. $ npm install
  2. $ bower install
  3. $ npm test

Licence:

MIT