idle-tracker
v0.1.3
Published
Tiny pure Javascript library to track browser inactivity
Downloads
29,097
Maintainers
Readme
Browsers support
| IE / Edge | Firefox | Chrome | Safari | iOS Safari | Samsung | Opera | | --------- | --------- | --------- | --------- | --------- | --------- | --------- | | Edge| last version| last 2 versions| last 2 versions| last 2 versions| last 2 versions| last 2 versions
Installation
via yarn
$ yarn add idle-tracker
or via npm
$ npm install idle-tracker
Usage
import IdleTracker from 'idle-tracker';
const idleTracker = new IdleTracker(options);
idleTracker.start(); // start tracker
idleTracker.end(); // stop tracker and release memory
Constructor options
| Options Name | Type | Default | Description |
| -------------- | -------- | ------- | ------------------------------------------------------------------------------------- |
| timeout (ms) | number | 30000 | timeout to count as idle |
| onIdleCallback | Function | noop | Function to be called when idle status change, payload will be { idle: true/false }
, with optional event
payload |
| throttle | number | 500 | throttle rate of callback |
Future
- Browser might support this function natively in the future, see Idle Detection API
- Related newer API/Library: page-lifecycle, repo