activity-detector
activity-detector copied to clipboard
timeToIdle of 30 minutes not working
Is there an upper limit of some kind to timetoIdle
? I'm using this to implement an auto logout. In tests at one minute or less, it works great. But when I set timeToIdle
to 1800000
, it fires the idle callback after about 10 seconds.
I had the same issue when trying to make for 60 mins
.... 3 Years later
For anyone else that ends up here like I did
The answer is in the init function
inactivityEvents.filter(eventName => eventName !== 'visibilitychange').forEach(eventName =>window.addEventListener(eventName, handleUserInactivityEvent));
if (inactivityEvents.indexOf('visibilitychange') >= 0 && visibilityChangeEvent) {document.addEventListener(visibilityChangeEvent, handleVisibilityChangeEvent);}
The init function has two types of extra listeners that no one realizes is there. These two listeners will run their call back, which can turn your timer to idle. In doing so, it looks like the timer doesn't work when that is not the case.
All you have to do is pass the settings to override the defaults for those two settings or copy and paste the code into your project and delete these specific lines in the init function.