Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/callumacrae/afk
:zzz: JavaScript library to handle user going inactive
https://github.com/callumacrae/afk
Last synced: 20 days ago
JSON representation
:zzz: JavaScript library to handle user going inactive
- Host: GitHub
- URL: https://github.com/callumacrae/afk
- Owner: callumacrae
- Created: 2015-02-03T16:17:36.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-17T15:46:37.000Z (almost 10 years ago)
- Last Synced: 2024-12-17T05:29:21.114Z (23 days ago)
- Language: JavaScript
- Homepage:
- Size: 152 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AFK.js
A library to tell whether your user is active or not and when they were last
active.Relies on jQuery for event emitting: use another library (probably using
EventEmitter) if your project doesn't already contain jQuery.## Install
```
$ npm install --save afk.js
```## Usage
```js
afk.on('inactive', function () {
console.log('User has gone inactive');
}).on('active', function () {
console.log('User has become active');
});afk.lastActive(); // Time the user was last active (or -1)
afk.isActive(); // Pretty descriptive, returns boolean
```The active event won't fire multiple times in a row, the inactive event has to
fire before it fires again.### Config
```js
afk.config.activeTime = 10000;
```The number of ms until the user is considered inactive.
```js
afk.config.visibility = true;
```If true, the page visibility API will be used to set the user inactive if the
page goes out of focus (e.g. the user changes to a different tab).## License
Released under the MIT license.