0.2.0 • Published 4 years ago

@js-factory/visibility v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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