A simple javascript library to detect browser idle and perform actions.
npm install @linkorb/idle
Check the demo/
directory for an demonstration + example on how to use idle.js
To support idle.js in your application, you'll need to include a script tag in your html:
<script type="text/javascript" src="../idle.js"></script>
You may specify some global variables to tweak the behaviors.
// set redirect url (relative) after idle timeout
_idle('url', '/demo/logout.html');
// set escaped urls that no need to detect idle, e.g. logout page
_idle('escape', ['/demo/logout.html']);
// specifying a callback to replace the default redirect action
_idle('callback', function(){console.log('timeout')});
// customize idle time interval, in ms.
_idle('interval', 2000);
// enable debug mode
_idle('debug', true);
To change the source file and build, simply use webpack
.
# generates dist/tweak.js
webpack -d
# generates dist/tweak.min.js
webpack -p
MIT (see LICENSE)
Check out our other projects at linkorb.com/engineering.
Btw, we're hiring!