JSPM

inactivejs

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 162
  • Score
    100M100P100Q74260F
  • License MIT

Detect when a user is idle or change tabs

Package Exports

  • inactivejs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (inactivejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.