I mean calling multiple requestAnimationFrame with the same function in one time
function Draw() { /* DoSomething */ }
function AFunc() {
/* prepare something */
requestAnimationFrame(Draw);
}
function BFunc() {
/* prepare something */
requestAnimationFrame(Draw);
}
window.onload(function(){
AFunc();
BFunc();
});
What will happen? Will it duplicated? Would it be called 2 times in the same frame? Or it would be stacked and called on difference frame?
From the MDN documentation:
(emphasis mine)
Also, from the spec:
and
So for your question:
The above all taken together shows that consecutive calls will be added to a list of callbacks, which will all be executed one after the other in the order they were added when the browser is due to run them, essentially duplicating the call to
Draw
in your code.