Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move to request animation frame

Conflicts:
	www/static/js/snow.js
  • Loading branch information...
commit f8c310f76f444fb20caad0407d5f80698739a934 1 parent 29f3976
Jake Archibald authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 www/static/js/snow.js
10 www/static/js/snow.js
View
@@ -1,6 +1,11 @@
(function() {
+ var requestAnimationFrame = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ function(func) { setTimeout(func, 17); };
+
var html = document.documentElement;
-
+
function Snowflake(maxX) {
var rand = Math.random();
var sizeRand;
@@ -122,6 +127,7 @@
context.closePath();
context.fill();
}
+ requestAnimationFrame(frame);
}
if (context) {
@@ -144,7 +150,7 @@
// add it to the page & start animating
document.body.appendChild(canvas);
document.body.appendChild(settleCanvas);
- setInterval(frame, 1000 / assumedFps);
+ requestAnimationFrame(frame);
}
})();
Please sign in to comment.
Something went wrong with that request. Please try again.