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 7565823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:15:17+00:00 2026-05-30T14:15:17+00:00

I have read lots of pages (also on stackoverflow) on how to fix this

  • 0

I have read lots of pages (also on stackoverflow) on how to fix this issue but nothing works for me. Below is the code I currently have:

    var initialFadeIn = 1000;           //initial fade-in time (in milliseconds)
    var itemInterval = 5000;            //interval between items (in milliseconds)
    var fadeTime = 2500;                    //cross-fade time (in milliseconds)

    var infiniteLoop = setTimeout(function(){
            position1.eq(currentItem1).stop(true, true).fadeOut(fadeTime);
            if(currentItem1 == numberOfItems1 -1) {currentItem1 = 0;}else{currentItem1++;}
            position1.eq(currentItem1).stop(true, true).fadeIn(fadeTime);
    }, itemInterval);

I added the .stop(true, true) but is still builds the animations and then displays all at once.

I also tried:

  infiniteLoop(itemInterval, fadeTime, position1, currentItem1, numberOfItems1);    

function infiniteLoop(itemInterval, fadeTime, position1, currentItem1, numberOfItems1) {
        setTimeout(function() {
                position1.eq(currentItem1).stop(true, false).fadeOut(fadeTime);
                if (currentItem1 == numberOfItems1 - 1) {
                        currentItem1 = 0;
                } else {
                        currentItem1++;
                }
                position1.eq(currentItem1).stop(true, false).fadeIn(fadeTime, infiniteLoop(itemInterval, fadeTime, position1, currentItem1, numberOfItems1));
        }, itemInterval);
}

but its just the same.

I was able to link it to window .focus()/.blur() but I would prefer it to stop of keep running in the background – eg: someone is using skype with the page in the background.

Any ideas I should try?

thankyou

  • 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-30T14:15:18+00:00Added an answer on May 30, 2026 at 2:15 pm

    This line of code is not right:

    position1.eq(currentItem1).stop(true, false).fadeIn(fadeTime, infiniteLoop(itemInterval, fadeTime, position1, currentItem1, numberOfItems1));
    

    You are supposed to be passing a function as the last argument to fadeIn() and that function will be called when the fadeIn() finishes. That is not what this line of code does. This line of code executes the infiniteLoop function at the beginning of the fadeIn() because you’re calling it right in the argument list and then passes the return value from that function to the fadeIn() function. This will indeed cause an infinite loop.

    Instead, you should be calling it like this:

    position1.eq(currentItem1).stop(true, false).fadeIn(fadeTime, function() {
        infiniteLoop(itemInterval, fadeTime, position1, currentItem1, numberOfItems1)
    });
    

    This passes an actual function to the fadeIn() call and that function will be called later when the fadeIn actually completes.

    The rest of your question sounds like maybe you’re trying to deal with the problem where Chrome and Firefox slow down timers when a tab goes to the background and then speed them up almost in a catchup mode when it comes to the foreground, there are solutions. I’m not sure exactly what kind of solution you want as you haven’t really explained that.

    The best solution is usually to stop your animations entirely when the tab goes to the background. Chrome offers an experimental page visibility API to allow you to do that. It’s a new event that you can listen to that tells you when the page becomes non-visible and when it becomes visible again and you can start/stop any long running timers upon those events.

    Here’s some sample code for using that API from the doc page:

    //startSimulation and pauseSimulation defined elsewhere
    
    function handleVisibilityChange() {
      if (document.webkitHidden) {
        pauseSimulation();
      } else {
        startSimulation();
      }
    }
    
    document.addEventListener("webkitvisibilitychange", handleVisibilityChange, false);
    

    Using .stop(true, true) will clear the animation queue and advance to the end of the animation for a given object before running the next animation, but isn’t really a fix for the general tab visibility/timer slowdown issue. The only real fix is to stop running the timers/animations in the background tabs.

    As a work-around in other browsers, some people keep track of when the focus leaves your window because that also happens when a tab goes to the background, though it’s imperfect because the window can still be visible, but in another browser window when it loses focus. Imperfect, but perhaps better than nothing.

    If you’re really asking something else, then please clarify exactly what your question is. You’ve posted a bunch of code, but not been real clear about what your question is.

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

Sidebar

Related Questions

I have read lots of questions and answers about this issue on StackOverflow, but
I am stuck with connecting to Oracle DB, have read lots of stuff but
I have read a lots document on NPAPI but I still do not understand:
I have read lots of information about page caching and partial page caching in
Before you run off and google, I have read lots of articles, posts, and
Given graph, how could i represent it using adj matrix?. I have read lots
From the .net 4.0 previews I have read until now there has been lots
I have read somewhere that HashMap uses chaining to resolve collisions. But if that
I have read lots these past few weeks on IE6, seeing if it was
I have read lots of programmers saying and writing when programming in C/C++ there

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.