angularjs interface of page visibility API
npm install @os33/angular_page_visibilityangular-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.
angular-page-visibility, just inject it, then listen to the events.``javascript
angular.module('app')
.controller('MyController', function($scope, $pageVisibility) {
$pageVisibility.$on('pageFocused', function(){
// page is focused
});
$pageVisibility.$on('pageBlurred', function(){
// page is blurred
});
});
`
1) include script: script can be included via bower or downloading directly
- via bower:
$ bower install angular-page-visibility
- download directly
`html`
2) include the module:
`javascript
angular.app('myApp', [ 'angular-page-visibility' ])
`
, grunt, karma are needed.1.
$ npm install
2. $ bower install
3. $ npm test`