1.0.3 • Published 9 years ago

afk.js v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

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

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

afk.config.activeTime = 10000;

The number of ms until the user is considered inactive.

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.

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago