react-activity-detector

1.1.8 • Public • Published

react-activity-detector 😴

npm License Build Status

Small and simple library to check if the user is idle.

Install

$ npm install --save react-activity-detector

How to use

Basic example

import ActivityDetector from 'react-activity-detector';

const customActivityEvents = [
    'click',
    'keydown',
];

const onIdle = () => {
console.log("The user seems to be idle...");
}

const onActive = () => {
console.log("The user is active!");
}

<ActivityDetector activityEvents={customActivityEvents} enabled={true} timeout={5*1000} onIdle={onIdle} onActive={onActive} name="default"/>

Parameter options

  • enabled: Boolean value indicating if the A.D. is enabled.
  • timeout time in milliseconds which will trigger onIdle
  • activityEvents: events used to detect if the user is active. Default list of Activity Events is ['click', 'mousemove', 'keydown', 'DOMMouseScroll', 'mousewheel', 'mousedown', 'touchstart', 'touchmove', 'focus']. If none event is sent the list will consume the default one.
  • name: in need of multiple Activity Detectors, provide a custom name. Default value is default.

/react-activity-detector/

    Package Sidebar

    Install

    npm i react-activity-detector

    Weekly Downloads

    3,657

    Version

    1.1.8

    License

    MIT

    Unpacked Size

    6.93 kB

    Total Files

    8

    Last publish

    Collaborators

    • the_architectus