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

ifvisible.OnEvery doesn't continue after switching tabs #45

Open
khaledosman opened this issue Mar 29, 2017 · 4 comments
Open

ifvisible.OnEvery doesn't continue after switching tabs #45

khaledosman opened this issue Mar 29, 2017 · 4 comments
Labels

Comments

@khaledosman
Copy link

khaledosman commented Mar 29, 2017

version: 2.0.10

I have the current code

ifvisible.setIdleDuration(900);

    ifvisible.idle(function() {
        console.log('idle')
        document.body.style.opacity = 0.5;
    });

    ifvisible.wakeup(function() {
        console.log('wakeup')
        document.body.style.opacity = 1;
    });

    // instead of setInterval, this will not call the callback if the user is idle
    ifvisible.onEvery(5, function() {
        console.log('interval');
    });

the interval initially gets called correctly, if I switch tabs then get back to the page "wakeup" is fired however the interval doesn't resume

@khaledosman khaledosman changed the title ifvisible.OnEvery doesn't continue called after switching tabs ifvisible.OnEvery doesn't continue after switching tabs Mar 29, 2017
@keskistok
Copy link

Any fix or workaround for this problem?

@khaledosman
Copy link
Author

@keskistok I rolled back to v1.0.6, seems to work there.

@bradydowling
Copy link

bradydowling commented Feb 28, 2019

I'm using v1.0.6 and this issue is still happening for me there. I'll likely have to set a timeout on blur and then clear it on focus like this:

      ifvisible.on('blur', () => {
        let blurredIdleTimeout;
        blurredIdleTimeout = setTimeout(() => {
          // it's idle, perform actions here
        }, MILLISECONDS_TO_IDLE);
      });
      ifvisible.on('focus', () => {
        clearTimeout(blurredIdleTimeout);
      });

@rosskevin
Copy link

I fixed this as of 3.0.1 on my fork https://github.com/rosskevin/ifvisible/releases

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

No branches or pull requests

5 participants