🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

Unfortunatelly the new RequestAnimationFrame API does not allow us to set the framerate, but using EasyAnimationFrame.js you can run html5 canvas or html animations having the complete control of the framerate. Using this script you get a complete cross browser suppor.

Animation Core Java Script HTML5

Documentation

What is EasyAnimationFrame for?

  • To make easy javascript loops ( optimized for animations ) using the new RequestAnimationFrame API
  • To control and get precisely the framerate of your loops
  • To stop and restart any kind of loop without using any javascript timer ( setTimeout or setInterval )
  • Thanks to the Paul Irish polyfill it is supported also by the old browsers ( IE7+ )

DEMO

[codepen.io] (http://codepen.io/GianlucaGuarini/full/GlEzv)


USAGE

You must create a new instance of the EAF class setting the loop function, the element you would like to animate (this could be also null), and eventually also the initial framedelay

OPTIONS

  • loop_Function : the function you want to loop
  • html_Element : { optional, by default is null } the DOM element you are manipulating ,generally it could be an HTML5 canvas
  • initial_frame_delay : { optional int, by default is 0} the time expressed in ms EAF should wait each frame before triggering the loop function
  var animator = new EAF(loop_Function, html_Element, initial_frame_delay);    animator.startAnimation(); 

#API (public methods)

  • startAnimation : it starts the animation with the inital frame delay ( with frame delay equal to 0 you can run your animation to the maximum browser speed).
  • clearAnimation : it stops immediately the animation.
  • getFrameDelay : this returns the current frame delay
  • updateFrameDelay: it updates the frame delay and could be used also on the fly
  • getFramerate: It returns the framerate of the current animation

You May Also Like