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).
The following events are available:
Name | Description |
---|---|
idle | The browser is idle. |
wakeup | The user has resumed activity. |
Name | Returned value | Description |
---|---|---|
start() | - | Starts tracking user activity. |
stop() | - | Stops tracking user activity. |
isIdle() | Boolean |
Checks the current state. |
Modifier | Acceptable values | Usage | Description |
---|---|---|---|
start | auto |
JS |
Automatically starts tracking user activity. |
The block is implemented in:
js
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
});
idle
eventGenerated when user activity ends.
wakeup
eventGenerated when user activity resumes.
start
methodStarts tracking user activity.
Doesn't accept arguments.
No return value.
modules.require(['idle'], function(idle) {
idle.start()
});
stop
methodStops 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
methodChecks 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
});
start
modifierAcceptable values: 'auto'
.
Usage: enabled in the deps.js
dependencies file.
Automatically starts tracking user activity.