ifvisible.js
ifvisible.js copied to clipboard
BUG: handled idle incorrect
If switch between tabs, any time I get "idle" if the time has not come: I expected get "focus" not "idle"
Example of code:
ifvisible.setIdleDuration(600); // 10 min == 600 sec
ifvisible.idle(function(){
console.log("ifvisible.idle handled");
});
Same here! I think that is pretty confusing if designed like this.
Yes the code is directly firing the idle event when blurred. Below is a workaround that will give you some mileage.
var idleInfo = ifvisible.getIdleInfo();
if (!idleInfo.isIdle) {
return;
}
A good fix could be to have a set method that enable/disables this behaviour.
thanks for the answer, handled this case myself in the meantime.
I agree, exposing this as a configureable setting would be really making this library complete.
Just ran into this issue, can't believe it hasn't been fixed since this issue was started over half a year ago.
@prabhu response works, but if you tab out, you will never be counted as idle. This will only work if you stay tabbed in.
@serkanyersen are you aware of this?
EDIT: I managed to fix it. Under blur: function(callback)
, change customEvent.fire(this, "idle");
to trackIdleStatus();
:+1:
Just fixed this issue in master. there was a minor race condition, and one of the timeouts were not clearing properly. it's all resolved now.
@serkanyersen did you test it? That didn't fix it for me.
if you are testing this on demo site, that's not updated yet.
I am not. I downloaded both the js and min js to test, and both don't work.
Wait I think I closed the wrong issue :/ I'll work on this one as well. sorry about that
Please take time with your fix. Ideally we would like to review the fix if possible since I feel this library is quite flaky as it is.
I'm actually porting the library into Typescript at the moment #33 . Which is going to be much more robust. I'll also have plenty of unit tests on that port.
Most of the bugs and low maintenance of this library happens because of coffee script. That was a bad choice :/
I can't seem to recreate this issue. Can someone give me step by step?
Also please checkout my comment on #38 any help is appreciated. Maybe V2 has solved this issue, I'm not sure.
Thanks
ifvisible.js prevent blur to trigger idle event as below http://blog.xuite.net/akira32/home/569372678