inactivejs
Detect when a user is idle or when he change tabs/apps. Small footprint package (5.47kb). Inspired by Idle.js
Usage
Install with npm/yarn:
npm install inactivejs yarn add inactivejs
Import on your js file:
const InactiveJS = ; ;
Instantiate:
const onAway = { console;}; const onBack = { console;}; const inactiveInstance = timeout: 5000 onAway: onAway onBack: onBack;
Config options:
- timeout (ms): how much time should wait
- onAway (callback): callback to be executed when the user is away
- onBack (callback): callback to be executed when the user is back
- onVisible (callback): callback to be executed when the tab is visible
- onHidden (callback): callback to be executed when the tab is hidden
- events (array): events to listen for
- autoStart (boolean): if start timer automatically
- throttle (ms): ms to throttle the event listeners, undefined/false to disable it
Available methods:
- start(): if you configured autoStart to false, this method will start the timer
- stop(): if needed, this will stop the timer
License
MIT.