Determines when the user is idle (not interacting with the page) so that you can respond appropriately.
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:
window.addEvents({ '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:
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus