@os33/angular_page_visibility

0.0.5 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @os33/angular_page_visibility

Weekly Downloads

2

Version

0.0.5

License

MIT

Unpacked Size

13.3 kB

Total Files

13

Last publish

Collaborators

  • jiansongos33
  • roger_os33