away
detect when a user is idle on a page
Last updated 8 years ago by shtylman .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install away 
SYNC missed versions from official npm registry.

away

detect idle users on webpages

browser support

var away = require('away');

// detect users who are idle for 10 seconds
var timer = away(10000);
timer.on('idle', function() {
    console.log('user is idle');
});
timer.on('active', function() {
    console.log('user is active');
});

api

away() returns a Timer object which exposes the following methods.

.on('idle', fn)

Call fn when user becomes idle.

.on('active', fn)

Call fn when user becomes active after having been idle.

.stop()

Stop the idle timer from detecting user activity

.start()

Start the idle timer. (By default the idle timer is started automatically)

options

idle() accepts a second argument with additional options.

element

The dom element to monitor for activity. (default document)

timeout

Milliseconds before user is considered idle. (default 30000)

events

String of DOM events that will trigger activity. (see index.js for default)

start

Whether to start idle timer upon creation. (default true)

install

npm isnstall away

credits

Inspired by the jquery-idletimer plugin.

Current Tags

  • 1.0.0                                ...           latest (8 years ago)

2 Versions

  • 1.0.0                                ...           8 years ago
  • 0.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |