idle-tracker
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

Idle Tracker

idle tracker


npm gzip size downloads Tiny Javascript library to track browser idle status. (callback when user is idle).

Demo

Browsers support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Samsung
Samsung
Opera
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

  1. Browser might support this function natively in the future, see Idle Detection API
  2. Related newer API/Library: page-lifecycle, repo

Package Sidebar

Install

npm i idle-tracker

Weekly Downloads

5,828

Version

0.1.3

License

MIT

Unpacked Size

282 kB

Total Files

32

Last publish

Collaborators

  • roderickhsiao