Closed sam327 closed 10 years ago
I would like to also know what the best way to pause, stop, and restart the timer.
+1
So, my goal was to hide a menu when idle and fade it back in when the mouse was moved again. UNLESS that particular menu was open, and then I wanted it to always be shown.
So, instead of ending/restarting the timer, I added an if-check on whether or not the menu was open.
Here's the start of the code:
var idletimeout = 3500
function idlecheck(){
$(document).bind("idle.idleTimer", function(){
if($("#mymenu").hasClass("collapsed")) {
} else {
$('#containerofmymenu').fadeOut(1000);
};
});
idlecheck();
There's also an active.idleTimer bit, and then another piece to restart the idletimer when I open and close that window.
Hope that's helpful to someone.
Later in the code, I've got a
It's not quite the solution I was looking for at the time, but it produced the results I wanted.
I believe my branch implements this correctly. https://github.com/thorst/jquery-idletimer/blob/master/src/idle-timer.js
Pause, resume, reset have been added in 1.0.0
I can get my function to start, and I can get it to stop, but I can't get it to restart again after stopping it.
I set up a button to disable the timer.
And then one to start it again.
Once the destroy item has been run, i can't start the idle timer at all.
Funny item is that if I don't have the idlecheck run on load, the "enabletimer" button will let make it start.
Is there a better way to pause or stop/restart the timer?