A tiny jquery plugin to call functions when a user goes idle, and then returns - per element.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE.txt
jquery.idle.js
readme.md

readme.md

jQuery.Idle

Simple script to notify you when the mouse has been inactive over a particular element for a customized period of time.

Stupid simple example:

$(document).ready(function() {  
  $("#content").idle(
    function() { 
      // When idle
      $("#content").fadeTo("slow",.1);
    }, 
    function() {
      // When active again
      $("#content").fadeTo("fast",1);
    }, 
    { after: 2000 }
  );
});

API:

$(selector).idle( onidle [, onactive, options])

The following are all valid ways to call this plugin:

  • $(selector).idle( onidle )
  • $(selector).idle( onidle, options )
  • $(selector).idle( onidle, onactive )
  • $(selector).idle( onidle, onactive, options )

You can globally override options before calling idle like this:

jQuery.fn.idle.defaults.active = 2500; // 2.5 seconds

Options:

key ( default )

  • after ( 5000 ):
    Number of milliseconds without movement before an element is considered idle
  • interval ( 100 ):
    Number of milliseconds between tests for movement