How can I pass argument with requestAnimationFrame?
You either need to create a reference or wrap the function call in another function like so:
mainFunc: function(x) {
anim.update(x);
anim.redraw(x);
window.requestAnimationFrame(function() {
anim.mainFunc(x);
});
}
You can also use .bind
.
mainFunc: function(x) {
anim.update(x);
anim.redraw(x);
window.requestAnimationFrame(anim.mainFunc.bind(anim,x));
}