Mootools based IdleTimer - determines when the user is idle (not interacting with the page) so that you can respond appropriately
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Determines when the user is idle (not interacting with the page) so that you can respond appropriately.


How to use

An easy setup of IdleTimer might be something like this:

var myIdleTimer = new IdleTimer(window, { timeout: 60000 });
myIdleTimer.addEvent('idle', function() {
	alert('You have been idle for 60 seconds!');

This would launch an alert box after the user has not moved his mouse button over the document, clicked any mouse/keyboard buttons or scrolled using the mouse scroll wheel.

If you want to use the default settings (60 second timeout), you can also do it even easier by doing something like this:

	'idle': function() { alert('60 seconds have passed!'); },
	'active': function() { alert('You just became active again!'); }

If you want to apply the IdleTimer to a specific element on the page, you can get an IdleTimer instance and set it's options like this:

$('myDiv').get('idle'); // Returns an IdleTimer instance
$('myDiv').set('idle', { timeout: 5000, events: ['mouseover', 'mousedown'] }); // Creates an IdleTimer instance with the given options (does not start it)


new IdleTimer(element, [options]);


1. element - (mixed) An Element or an id string.
2. options - (object, optional) the options described below:


  • timeout : (number) Number of idle milliseconds before firing the idle event. Defaults to 60000 (one minute).
  • events : (array) Event names that trigger the active event (resets the idle time). Defaults to ['mousemove', 'keydown', 'mousewheel', 'mousedown']


  • idle : Fired when the user has reached the set amount of idle milliseconds.
  • active : Fired when the user becomes active.
  • start : Fired when the events have been added and the timer is starting for the first time.
  • stop : Fired when the timer has been stopped and the events have been removed.
  • timeoutChanged : Fired when the threshold for idle milliseconds has been set to a new value. Gets passed the new value.