Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6324165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:39:12+00:00 2026-05-24T16:39:12+00:00

Looking at other questions here they seem to report setInterval is disabled or slowed

  • 0

Looking at other questions here they seem to report setInterval is disabled or slowed down when a tab is hidden. I am seeing a different problem – calls to setInterval appear to “stack” and then all get applied when the tab is shown.

In my case I have a slider which animates an image on the site homepage every few seconds. If I go to another tab for a minute or two then return, the slider goes crazy… all the animations fire one after another until it is caught up.

I tried adding code to stop the animation happening if another is already in progress, but it doesn’t work… maybe the timer events get queued in some way that circumvents my test.

   setInterval(function(){
                    if (!rotationQueued) {
                                        rotationQueued = true;
                                        rotate_slide('next');
                                    }
                         }

So, I want the JS to pause when the tab is hidden – or to act as normal – anything but this!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:39:12+00:00Added an answer on May 24, 2026 at 4:39 pm

    You could try something like this:

    function runRotate() {
        return window.setInterval(function(){
            if (!rotationQueued) {
                rotationQueued = true;
                rotate_slide('next');
            }
        });
    }
    
    var run = runRotate();
    
    window.addEventListener('focus', function() {
        run = runRotate();
    },false);
    
    window.addEventListener('blur', function() {
        window.clearInterval(run);
    },false);
    

    You would basically look to see if the browser window is focused or not and then run or disable the setInterval function depending on the event returned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of other questions on here surrounding this area but they
There are some other similar questions here but they're fairly old when Rails 3
I have checked other questions here at SO, however they do not answer my
I've tried to follow the other questions, but I don't think that they are
Been looking through other answers and I still don't understand the modulo for negative
Is it possible to change the default text (something like looking for other iPhones
After looking a while other google, and the web, I decided to post my
Looking for the correct preg_match (or other solution) to validate a string to go
I'm looking for feedback on what other people use on their ASP.NET projects to
I was looking at some code length metrics other than Lines of Code. Something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.