0.0.5 • Published 5 years ago

@os33/angular_page_visibility v0.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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>

2) 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