Skip to content

A tiny jquery plugin to call functions when a user goes idle, and then returns - per element.

License

Notifications You must be signed in to change notification settings

jasonmcleod/jquery.idle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

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

About

A tiny jquery plugin to call functions when a user goes idle, and then returns - per element.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published