Solved

jQuery animation faster

Posted on 2016-11-09
1
47 Views
Last Modified: 2016-11-23
How do I control the speed of the following animation?

<script>
(function() {
  var requestAnimationFrame1 = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
                              window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
  window.requestAnimationFrame = requestAnimationFrame1;
})();
 var canvas1 = document.getElementById('canvas1');
 var context1 = canvas1.getContext('2d');
 var x1 = canvas1.width / 2;
 var y1 = canvas1.height / 2;
 var radius1 = 63;
 var endPercent1 = 90;
 var curPerc1 = 0;
 var counterClockwise1 = false;
 var circ1 = Math.PI * 2;
 var quart1 = Math.PI / 2;

 context1.lineWidth = 13;
 context1.strokeStyle = '#d32128';
 context1['imageSmoothingEnabled'] = false;       /* standard */
    context1['mozImageSmoothingEnabled'] = false;    /* Firefox */
    context1['oImageSmoothingEnabled'] = false;      /* Opera */
    context1['webkitImageSmoothingEnabled'] = false; /* Safari */
    context1['msImageSmoothingEnabled'] = false;     /* IE */



 function animate1(current) {
     //context.clearRect(0, 0, canvas.width, canvas.height);
     context1.beginPath();
     context1.arc(x1, y1, radius1, -(quart1), ((circ1) * current) - quart1, false);
     context1.stroke();
     curPerc1++;
     if (curPerc1 < endPercent1) {
         requestAnimationFrame(function () {
             animate1(curPerc1 / 100)
         });
     }
 }

</script>

Open in new window

0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 56

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41880966
Change line 33.

To make it faster add more than 1
To make it slower add less than 1

Faster
curPerc1+=2; // twice as fast

Open in new window

Slower
curPerc1+=0.5 /half as fast

Open in new window

0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help with this homework problem. 5 62
HTML auto refresh to another site 4 31
Duplicate Elements with JS / jQuery 3 26
javascript form - error when hitting enter 3 28
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question