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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:01:22+00:00 2026-06-18T08:01:22+00:00

I have written a function window.setinterval followed by two if conditions. Working absolutely as

  • 0

I have written a function window.setinterval followed by two if conditions. Working absolutely as I wanted in Firefox, Opera, IE. In webkit engines, the function is not being carried forward.

 x = window.setInterval(function() {
            if(a.speed >= a.maxSpeed && b.speed >= b.maxSpeed && c.speed >= c.maxSpeed) {
                 a.stop();
                 b.stop();
                 c.stop();
            }
            if(a.speed === 0 && b.speed === 0 && c.speed === 0 && completed === 3) {
                window.clearInterval(x);
                enableControl();
                printResult();
                enableControl(); 
            }
        }, 100);

I’ve set an interval where when max.speeds are reached, stop function should be called and If speeds are 0, the result should be displayed. In Mozilla, IE, Opera its working exactly as I wanted. But in webkit, the first if condition itself isn’t being executed. An infinite loop is running.

I’ve tried nested if also, even then the first if condition isn’t being executed. Please help me resolve this issue.

If this isn’t a correct approach, can I trigger a timeout after c.stop() and manually make the speed’s of a,b,c to 0 and then enable control and display result?

This the stop function you asked for:

 Slot.prototype.stop =        function() {
    var _this = this,
        limit = 30;
    clearInterval(_this.si);
    _this.si = window.setInterval(function() {
        if(_this.speed > limit) {
            _this.speed -= _this.step;
            $(_this.el).spSpeed(_this.speed);
        }
        if(_this.speed <= limit) {
            _this.finalPos(_this.el);
            $(_this.el).spSpeed(0);
            $(_this.el).spStop();
            clearInterval(_this.si);
            $(_this.el).removeClass('motion');
            _this.speed = 0;
        }
    }, 100);
};
  • 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-18T08:01:23+00:00Added an answer on June 18, 2026 at 8:01 am

    If you’ll excuse an answer that kind of sidesteps your question, there are arguments that you should really not be using setInterval anyway (see this and this). The strength of the guarantee regarding the time interval is OS and browser dependent, and therefore not very strong. You’re better off using setTimeout to schedule a function that reschedules itself using setTimeout when necessary. If you’re worried about the exactness of the interval, you can always adjust the time interval to real time as you see fit.

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

Sidebar

Related Questions

I have this following code: $(window).load(function() { $('#content1').load('database.php'); setInterval (function() { $.post('status.php', { id:
I have written a utility function which expects the window object to work on.
I have written a DLL which exports a function that creates a window using
I have written a function that sorts a big scale of data. To test
I have written a function that extract the domain from hostname. e.g. www.domain.com ->
I have written this function to auto correct gender to M or F from
I have written a function which warn a user before refreshing the (I require
I have written a function that positions a tooltip just above a textbox. The
I have written a function below: void trans(double x,double y,double theta,double m,double n) {
I have written a function for a multilevel wordpress menu, but I'd like it

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.