Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

jQuery animation faster

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

ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial