ifvisible.js icon indicating copy to clipboard operation
ifvisible.js copied to clipboard

BUG: handled idle incorrect

Open sea5kg opened this issue 9 years ago • 13 comments

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");
});

sea5kg avatar Dec 23 '15 12:12 sea5kg

Same here! I think that is pretty confusing if designed like this.

roundrobin avatar Dec 30 '15 19:12 roundrobin

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.

prabhu avatar Feb 05 '16 10:02 prabhu

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.

roundrobin avatar Feb 08 '16 19:02 roundrobin

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:

maybecryptic avatar Jul 09 '16 19:07 maybecryptic

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 avatar Jul 09 '16 21:07 serkanyersen

@serkanyersen did you test it? That didn't fix it for me.

maybecryptic avatar Jul 09 '16 21:07 maybecryptic

if you are testing this on demo site, that's not updated yet.

serkanyersen avatar Jul 09 '16 21:07 serkanyersen

I am not. I downloaded both the js and min js to test, and both don't work.

maybecryptic avatar Jul 09 '16 21:07 maybecryptic

Wait I think I closed the wrong issue :/ I'll work on this one as well. sorry about that

serkanyersen avatar Jul 09 '16 21:07 serkanyersen

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.

prabhu avatar Jul 11 '16 14:07 prabhu

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 :/

serkanyersen avatar Jul 11 '16 19:07 serkanyersen

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

serkanyersen avatar Nov 10 '16 07:11 serkanyersen

ifvisible.js prevent blur to trigger idle event as below http://blog.xuite.net/akira32/home/569372678

akira32chen avatar Mar 06 '18 14:03 akira32chen