From 7a351e5ae1a65da9c50131ead7ae5bf221b1837e Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Thu, 8 Jan 2015 15:24:48 +0330 Subject: [PATCH] cross-browser requestAnimationFrame --- main.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 5a43fad..4583b90 100644 --- a/main.js +++ b/main.js @@ -27,8 +27,14 @@ function add(x, y) { }); } +var reqAnimationFrame = mozRequestAnimationFrame || + webkitRequestAnimationFrame || + msRequestAnimationFrame || + oRequestAnimationFrame || + requestAnimationFrame; + (function loop() { - mozRequestAnimationFrame(function() { + reqAnimationFrame(function() { c.clearRect(0, 0, $c.width, $c.height); for( var i = 0; i < balls.length; i++ ) {