Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chrisbloom7 opened this issue Oct 11, 2013 · 2 comments
Open

Comments

@chrisbloom7
Copy link

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.

@shawnmclean
Copy link
Owner

I'll look into it soon.

@chrisbloom7
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants