Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

afk.js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

afk.js

JavaScript library to handle user going inactive

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33
decreased by-21.43%
Maintainers
1
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 17 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc