Skip to content

Commit f8c310f

Browse files
committed
Move to request animation frame
Conflicts: www/static/js/snow.js
1 parent 29f3976 commit f8c310f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

www/static/js/snow.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
(function() {
2+
var requestAnimationFrame = window.requestAnimationFrame ||
3+
window.webkitRequestAnimationFrame ||
4+
window.mozRequestAnimationFrame ||
5+
function(func) { setTimeout(func, 17); };
6+
27
var html = document.documentElement;
3-
8+
49
function Snowflake(maxX) {
510
var rand = Math.random();
611
var sizeRand;
@@ -122,6 +127,7 @@
122127
context.closePath();
123128
context.fill();
124129
}
130+
requestAnimationFrame(frame);
125131
}
126132

127133
if (context) {
@@ -144,7 +150,7 @@
144150
// add it to the page & start animating
145151
document.body.appendChild(canvas);
146152
document.body.appendChild(settleCanvas);
147-
setInterval(frame, 1000 / assumedFps);
153+
requestAnimationFrame(frame);
148154
}
149155
})();
150156

0 commit comments

Comments
 (0)