Board Game Experiment, with JS Prototypes and Canvas

Set requestAnimationFrame

Okay. We’re going to use some animations. Paul Irish wrote an awesome post about requestAnimationFrame, what’s coming here is an ugly copy and paste of the master’s work on the subject.

// We set the requestAnimationFrame as Paul Irish told us to.
(function(){for(var d=0,a=["ms","moz","webkit","o"],b=0;b<a.length&&!window.requestAnimationFrame;++b)window.requestAnimationFrame=window[a[b]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[a[b]+"CancelAnimationFrame"]||window[a[b]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(b){var a=(new Date).getTime(),c=Math.max(0,16-(a-d)),e=window.setTimeout(function(){b(a+c)},c);d=a+c;return e});window.cancelAnimationFrame||(window.cancelAnimationFrame=function(a){clearTimeout(a)})})();