Tiny jQuery Plugin For User Activity / Idle Detection - idleCat
File Size: | 7.82 KB |
---|---|
Views Total: | 1361 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
idleCat is a lightweight jQuery plugin that helps detect your user is active or inactive(idle) on the web page and then execute corresponding callback functions.
How to use it:
1. Link to the jQuery idleCat plugin's script at the bottom of your web project. Make sure you have the latest version of jQuery also loaded.
<script src="jquery.min.js"></script> <script src="jquery.idleCat.min.js"></script>
2. Create a new instance of idleCat and pass the options to the idleCat
function as shown below.
var idleTimer = $('#status').idleCat({ // Number of seconds to wait between two scans of user activity. interval: 2, // How many seconds to hold the activity from the moment of knowing there was not any activity. release: 2, // The default state of the idleness (use 'active' or 'idle'). state: 'idle', // Callback fired after the discovery of user activity on the page. activeCallback: function() { $(this).addClass('active'); }, // Callback fired after the discovery of used idleness on the page. // (+ number of seconds defined in the 'release' property) idleCallback: function(element) { $(this).removeClass('active'); }, });
Change log:
2016-05-21
- Minor improvements in code
This awesome jQuery plugin is developed by smuuf. For more Advanced Usages, please check the demo page or visit the official website.