@js-factory/visibility
v0.2.0
Published
Page Visibility API Implementation for single page applications
Downloads
1
Readme
visibility
Page Visibility API implementation
Installation
npm i -S @js-factory/visibility
Usage
import onVisibilityChange from '@js-factory/visibility';
import { h, Component } from 'preact';
export default class AppWrapper extends Component{
...
...
componentDidMount(){
onVisibilityChange();
}
}
API
onVisibilityChange(options, handler);
options -- refreshTime - this is used to decide when to refresh the window when visiblity changes. DEFAULT_VALUE: 120000 ms -- scrollToTop - Set browser scroll position to (0,0). DEFAULT_VALUE: true
handler custom handler function to be executed when visibility of page is changes