In my javascript code, I create a foo object.
I create a draw() method.
In my foo object, window.requestAnimationFrame() is a value of a foo property called foo.requestAnimationFrame.
But when I call foo.requestAnimationFrame(foo.draw) to execute foo.draw again, it doesn't work because console javascript in chrome displays this error :
Uncaught TypeError: Illegal invocation
Here my javascript code :
var foo = {
"init" : function()
{
foo.requestAnimationFrame = window.requestAnimationFrame();
//Draw :
foo.draw();
},
"draw" : function()
{
console.log("Drawing");
foo.requestAnimationFrame(foo.draw);
}
};
foo.init();
So Why it doesn't work ? Thank you very much.