Skip to content

mz026/angular_page_visibility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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