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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:22:39+00:00 2026-06-07T08:22:39+00:00

I’m trying to create an animation using HTML5 canvas and Javascript. I have very

  • 0

I’m trying to create an animation using HTML5 canvas and Javascript. I have very little prior knowledge of Javascript. The first part of the animation is to make a circle ‘grow’ until the edge touches a cross. The cross then moves along the edge of the circle. Individually, these parts work fine but, as I’m using setInterval(), both animations play at the same time rather than waiting for the first to finish before starting the second.

What would be the easiest way to do this? I would be happy using HTML buttons, but <button onclick="setInterval(aRot,30);">Next Step</button> doesn’t seem to work.

​My ‘orrible ‘odgepodge of code is viewable at http://jsfiddle.net/jtYkN/12/

  • 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-07T08:22:41+00:00Added an answer on June 7, 2026 at 8:22 am

    First off you really want to use requestAnimationFrame rather than setInterval. Its made specifically for animations. According to paul irish..

    Why should I use it?

    The browser can optimize concurrent animations together into a single
    reflow and repaint cycle, leading to higher fidelity animation. For
    example, JS-based animations synchronized with CSS transitions or SVG
    SMIL. Plus, if you’re running the animation loop in a tab that’s not
    visible, the browser won’t keep it running, which means less CPU, GPU,
    and memory usage, leading to much longer battery life.

    Heres how I would implement what your talking about

    // all credit to paul irish on this part
    window.requestAnimFrame = (function(){
      return  window.requestAnimationFrame       || 
              window.webkitRequestAnimationFrame || 
              window.mozRequestAnimationFrame    || 
              window.oRequestAnimationFrame      || 
              window.msRequestAnimationFrame     || 
              function( callback ){
                window.setTimeout(callback, 1000 / 60);
              };
    })();
    
    
    function growCircle () {
      // code to make the circle bigger
    }
    
    
    function rotateCross() {
      // code to make the cross rotate
    }
    
    (function animate(){
      requestAnimFrame(animate);
      if ( /* code to tell if the circle has finished growing */ ) {
        rotateCross();
      } else {
        growCircle();
      }
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
We're building an app, our first using Rails 3, and we're having to build
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I don't have much knowledge about the IPv6 protocol, so sorry if the question

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.