JSFiddle - React, Tailwind, and code Playground
JavaScript
var Engine = function(model) {
this.model = model;
};
Engine.prototype.start = function() {
console.log("ready");
this.requestAnimationFrame(function() {
console.log("done");
});
};
Engine.prototype.updateUi = function() {
console.log("update ui");
this.requestAnimationFrame(this.updateUi);
};
Engine.prototype.logRAF = function() {
console.log(window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame);
return this;
};
Engine.prototype.requestAnimationFrame = (window.requestAnimationFrame && window.requestAnimationFrame.bind(window)) ||
(window.webkitRequestAnimationFrame && window.webkitRequestAnimationFrame.bind(window)) ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element){
window.setTimeout(callback, 1000 / 60);
};
var engine = new Engine();
engine.logRAF().start();