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

window 'blur' and 'focus' not handled #42

Open
akania opened this issue Jan 9, 2017 · 1 comment
Open

window 'blur' and 'focus' not handled #42

akania opened this issue Jan 9, 2017 · 1 comment

Comments

@akania
Copy link

akania commented Jan 9, 2017

When window gets or loses focus 'blur' and 'focus' event callbacks are not called.
I expect that these will be triggered
ifvisible.on('blur', () => console.log('ifvisible blur callback'))
ifvisible.on('focus', () => console.log('ifvisible focus callback'))

Standard window events are triggered as expected
window.addEventListener('blur', () => console.log('window blur'))
window.addEventListener('focus', () => console.log('window focus'))

@serkanyersen
Copy link
Owner

ifvisible runs on the Page Visibility Api

it only works in these situations:

  • visible : the page content may be at least partially visible. In practice this means that the page is the foreground tab of a non-minimized window.
  • hidden : the page content is not visible to the user. In practice this means that the document is either a background tab or part of a minimized window, or the OS screen lock is active.

Implementation of these events might differ from browser to browser. Clicking outside of the window or switching to a different app while browser is still visible, will not trigger these events.

In the latest version, I've included a new method called ifvisible.legacyMode() if you run this method, it will work like you wanted.

Latest version here:
https://github.com/serkanyersen/ifvisible.js/releases/tag/v2.0.10

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