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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:10:29+00:00 2026-06-14T03:10:29+00:00

I made some script to make a countdown on my site, it loops on

  • 0

I made some script to make a countdown on my site, it loops on all deadline classes and changes the clock.

Here’s the code

self.setInterval(function(){
$('.deadline_container').each(function(){
    days = parseInt($(this).children('.deadline_days').html(),10);
    time = $(this).children('.deadline_time').html().split(':');
    hours = parseInt(time[0],10);
    minutes = parseInt(time[1],10);
    seconds = parseInt(time[2],10);
    if(seconds > 0){
        seconds -= 1;
    } else if(minutes > 0){
        minutes -= 1;
        seconds = 59;
    } else if(hours > 0){
        hours -= 1;
        minutes = 59;
        seconds = 59;
    } else if(days > 0){
        days -= 1;
        hours = 23;
        minutes = 59;
        seconds = 59;
    }
    sec = (seconds < 10) ? '0' + seconds : seconds;
    min = (minutes < 10) ? '0' + minutes : minutes;
    hh = (hours < 10) ? '0' + hours : hours;
    $(this).children('.deadline_days').html(days);
    $(this).children('.deadline_time').html([hh,min,sec].join(':'));
});
}, 1000);

I have some code too to show an overlay on a div when hovering it

$('.someDivClass').live({
    mouseover: function() {
        $(this).children('.background').children('.overlay').stop().animate({opacity:"1"}, 300);
    },
    mouseout: function() {
         $(this).children('.background').children('.overlay').stop().animate({opacity:"0"}, 300);
    }
});

That two pieces of code works great, there isn’t any problem with the animations, the problem is that when the interval is running and I hover one of the divs with overlay, the overlay animation freezes until the countdown ticks one second. Sometimes it looks like there’s no animation and just the overlay appears from sudden. Sometimes looks good, it all depends on the instant when I hover the div. I think the setInterval function stops the animation queue until it stops executing it’s own code.

I think there’s no threading on jquery or something similar.

So the questions are:

¿How can I make my overlays animations smooth without depending of the clock interval?

¿Is there a more efficient way to do my countdown or overlay animations?

I’m using jquery 1.8.2 and jQuery UI 1.9.0

Edit

I didn’t realize it before, I have an opacity change too, like this:

$('#top_bar, #top_bar_container').hover(
    function(event){
        $(this).stop().animate({backgroundColor:"rgba(0,0,0,0.5)"}, 300);
    },
    function(event){
        $(this).stop().animate({backgroundColor:"rgba(0,0,0,0.2)"}, 1000);
    }
);

That animation runs smoothly no matter what!
So it could be the live function (I need it as I add content to the page with AJAX) or the opacity animation against the background animation (could be more expensive on CPU terms)

Any help would be appreciated, thanks.

Edit
Here’s my DOM

<div class="someDivClass">
    <div class="background">
        <div class="overlay">
            <div class="deadline">
                <div>Time Left</div>
                <div class="deadline_container">
                    <div class="deadline_days">14</div>
                    <div class="deadline_time">23:20:51</div>
                    <div style="clear:both;"></div>
                </div>
            </div>
        </div>
    </div>
</div>  

I have a lot of this containers on my page.

  • 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-06-14T03:10:30+00:00Added an answer on June 14, 2026 at 3:10 am

    I solved this.
    Actually it wasn’t a jQuery animate or javascript setInterval() problem, it was Google Chrome itself.

    I tried this:

    As philipp said, I changed the first code to setTimeout()

    I changed the .live() to $(document).on(‘mouseover’, ‘.someDivClass’, function(){…});

    But none of this solved the problem, so testing things here and there I optimized the images on my site, and it was solved!

    What I think that happens:
    Chrome has problem rendering animated divs with opacity background on top of LARGE images, because when I made the .background class image smaller the animation lag dissapeared.

    I tested the code I had at the beginning on Firefox 15.0.1 and there was no lag at all.

    Thanks for the answers anyway, I don’t have problems with animations anymore

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

Sidebar

Related Questions

Hey I was trying to call a script to made some changes to an
I have made a feedback form.i put some jquery code to make it animate
I have made a script which slides thought some customers quotes. See code below
I have made a script that run various loops and does some SQL inserts.
I'm doing some animation script in RPG Maker XP (made with ruby) that allow
I made some modifications to SVG Edit which contains a make file. When I
I made some code to produce boxes every time my code encounters a white
I made some changes to an open source project without taking time to create
I made some code, for understanding the concept/basic of pointer: int a=1; int *b=&a;
I made some Eclipse plugin and update site on Indigo(Eclipse v3.7). I can debug

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.