Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

inactivejs

Package Overview
Dependencies
1
Maintainers
2
Versions
3
Issues
File Explorer

Advanced tools

inactivejs

Detect when a user is idle or change tabs

    0.1.1latest

Version published
Maintainers
2
Yearly downloads
4,160
increased by188.49%

Weekly downloads

Changelog

Source

Version 0.1.1

Bug fixes

  • #3 : Idle check not working when calling with only one callback (onAway or onBack)

Readme

Source

inactivejs

Build Status

Detect when a user is idle or when he change tabs/apps. Small footprint package (5.47kb). Inspired by Idle.js

Usage

Install with npm/yarn:

npm install inactivejs yarn add inactivejs

Import on your js file:

const InactiveJS = require('inactivejs'); import InactiveJS from 'inactivejs';

Instantiate:

const onAway = () => { console.log('user is away'); }; const onBack = () => { console.log('user is back'); }; const inactiveInstance = new InactiveJS({ timeout: 5000, onAway: onAway, onBack: onBack, });

Config options:

  • timeout (ms): how much time should wait
  • onAway (callback): callback to be executed when the user is away
  • onBack (callback): callback to be executed when the user is back
  • onVisible (callback): callback to be executed when the tab is visible
  • onHidden (callback): callback to be executed when the tab is hidden
  • events (array): events to listen for
  • autoStart (boolean): if start timer automatically
  • throttle (ms): ms to throttle the event listeners, undefined/false to disable it

Available methods:

  • start(): if you configured autoStart to false, this method will start the timer
  • stop(): if needed, this will stop the timer

License

MIT.

Keywords

Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc