Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions modes/canvas/surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ var Class = require('../../core/class');
var Container = require('../../dom/container');
var Element = require('../../dom/native');

(function() {
if (window.requestAnimationFrame) {
return;
}

var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var i = 0; i < vendors.length; i++) {
var rafName = vendors[i] + 'RequestAnimationFrame';
if (window[rafName]) {
window.requestAnimationFrame = window[rafName];
break;
}
}
})();

var fps = 1000 / 60, invalids = [], renderTimer, renderInvalids = function(){
clearTimeout(renderTimer);
renderTimer = null;
Expand Down Expand Up @@ -102,9 +117,9 @@ var CanvasSurface = Class(Element, Container, {
this._valid = false;
invalids.push(this);
if (!renderTimer){
if (window.mozRequestAnimationFrame){
if (window.requestAnimationFrame){
renderTimer = true;
window.mozRequestAnimationFrame(renderInvalids);
window.requestAnimationFrame(renderInvalids);
} else {
renderTimer = setTimeout(renderInvalids, fps);
}
Expand Down