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

Idle.js interprets page navigation in Firefox as being "away"

Open chrisbloom7 opened this issue 12 years ago • 2 comments

If you go to http://shawnmclean.github.io/Idle.js/ in Firefox and refresh the page, you'll briefly see idle.js report that "User is not looking at page" before the page repaints. This is also happening in a dashboard app that I have whenever a user clicks on any link that takes them away from the dashboard - the "background polling paused" message I have setup is displayed for a second while Firefox is busy loading the new page.

chrisbloom7 avatar Oct 11 '13 17:10 chrisbloom7

I'll look into it soon.

shawnmclean avatar Oct 11 '13 18:10 shawnmclean

Thanks. Here's a quick work around for anyone that needs it:

// Requires jQuery < 1.9, or https://github.com/gabceb/jquery-browser-plugin

function idlePause() {
  // ...
};

function idleResume() {
  // ...
};

function supportsIdleJs(){
  // See: https://github.com/shawnmclean/Idle.js/issues/7
  return !$.browser.msie || parseInt($.browser.version) > 8;
};

function supportsVisible(){
  // Idle.js interprets page navigation in Firefox as being "away"
  // See: https://github.com/shawnmclean/Idle.js/issues/9
  return supportsIdleJs() && !$.browser.mozilla;
};

var idler = new Idle({
  onAway:      supportsIdleJs()  ? idlePause  : jQuery.noop,
  onAwayBack:  supportsIdleJs()  ? idleResume : jQuery.noop,
  onHidden:    supportsVisible() ? idlePause  : jQuery.noop,
  onVisible:   supportsVisible() ? idleResume : jQuery.noop,
  awayTimeout: 5000,
});

chrisbloom7 avatar Oct 11 '13 18:10 chrisbloom7