EN RU
Forum

Methodology

Technology

Toolbox

Libraries

Tutorials

DocumentationJSDocSource

idle

This block provides an object with a set of methods for generating an event when user activity ends (i.e. the user switches to another window or doesn't finish actions).

Overview

Object events

The following events are available:

Name Description
idle The browser is idle.
wakeup The user has resumed activity.

Properties and methods of the object

Name Returned value Description
start() - Starts tracking user activity.
stop() - Stops tracking user activity.
isIdle() Boolean Checks the current state.

Block modifiers

Modifier Acceptable values Usage Description
start auto JS Automatically starts tracking user activity.

Public block technologies

The block is implemented in:

  • js

Description

Subscribing to the block's event allows you to suspend operations, such as displaying animation, when there isn't any user activity.

The block is a descendant of the Emitter class in the events block, which allows it to call these methods.

modules.require(['idle'], function(idle) {

idle
    .on({
        idle : function() {
            // idle event handler
        },
        wakeup : function() {
            // wakeup event handler
        }
    })
    .start(); // start event generation

});

Object events

idle event

Generated when user activity ends.

wakeup event

Generated when user activity resumes.

Properties and methods of the object

start method

Starts tracking user activity.

Doesn't accept arguments.

No return value.

modules.require(['idle'], function(idle) {

idle.start()

});

stop method

Stops user activity tracking.

Doesn't accept arguments.

No return value.

modules.require(['idle'], function(idle) {

idle.start() // start tracking activity
idle.stop() // stop tracking activity

});

isIdle method

Checks whether there is any user activity.

Doesn't accept arguments.

Return value: Boolean. If there isn't any activity, true.

modules.require(['idle'], function(idle) {

idle.isIdle() // true or false, depending on the current state

});

Block modifiers

start modifier

Acceptable values: 'auto'.

Usage: enabled in the deps.js dependencies file.

Automatically starts tracking user activity.

Instance methods:
start
stop
isIdle

Module idle

Instance methods:

start()
description
Starts monitoring of idle state
stop()
description
Stops monitoring of idle state
isIdle():Boolean
description
Returns whether state is idle