Skip to content

fireworkweb/inactivejs

Repository files navigation

inactivejs

Build Status

Detect when a user is idle. No dependencies, small footprint (2.35kb). Inspired by Idle.js

Usage

Install with npm/yarn:

npm install inactivejs

yarn add inactivejs

Import on your js file:

const InactiveJS = require('inactivejs');

import InactiveJS from 'inactivejs';

Instantiate:

const onAway = () => {
    console.log('user is away');
};

const onBack = () => {
    console.log('user is back');
};

const inactiveInstance = new InactiveJS({
    timeout: 5000,
    onAway: onAway,
    onBack: onBack,
});

Options:

  • timeout (ms): How much time should wait
  • onAway: callback to be executed when the user is away
  • onBack: callback to be executed when the user is back

License

MIT.

About

Detect when a user is idle. No dependencies, small footprint (5.47kb).

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors