Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roderickhsiao/idle-tracker
Javascript library to track browser inactivity
https://github.com/roderickhsiao/idle-tracker
brower idle javascript
Last synced: about 10 hours ago
JSON representation
Javascript library to track browser inactivity
- Host: GitHub
- URL: https://github.com/roderickhsiao/idle-tracker
- Owner: roderickhsiao
- License: mit
- Created: 2019-02-05T07:17:43.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-31T14:54:16.000Z (4 months ago)
- Last Synced: 2024-12-26T11:06:05.083Z (8 days ago)
- Topics: brower, idle, javascript
- Language: HTML
- Homepage: https://roderickhsiao.github.io/idle-tracker/test/
- Size: 1.44 MB
- Stars: 19
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Idle Tracker
Tiny Javascript library to track browser idle status. (callback when user is idle).
[Demo](https://roderickhsiao.github.io/idle-tracker/test/)
## Browsers support
| [](http://godban.github.io/browsers-support-badges/)
IE / Edge | [](http://godban.github.io/browsers-support-badges/)
Firefox | [](http://godban.github.io/browsers-support-badges/)
Chrome | [](http://godban.github.io/browsers-support-badges/)
Safari | [](http://godban.github.io/browsers-support-badges/)
iOS Safari | [](http://godban.github.io/browsers-support-badges/)
Samsung | [](http://godban.github.io/browsers-support-badges/)
Opera |
| --------- | --------- | --------- | --------- | --------- | --------- | --------- |
| Edge| last version| last 2 versions| last 2 versions| last 2 versions| last 2 versions| last 2 versions## Installation
via [yarn](https://yarnpkg.com/en/docs)
```
$ yarn add idle-tracker
```or via [npm](https://docs.npmjs.com/)
```
$ npm install idle-tracker
```## Usage
```js
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](https://web.dev/idle-detection/)
1. Related newer API/Library: [page-lifecycle](https://developers.google.com/web/updates/2018/07/page-lifecycle-api), [repo](https://github.com/GoogleChromeLabs/page-lifecycle)