How can I pass argument with requestAnimationFrame?

后端 未结 3 1107
情书的邮戳
情书的邮戳 2020-12-09 16:12

In the main program I randomly choose an object which I\'d like to animate, so I call the function with the object as the argument. The first loop is okay, x is

3条回答
  •  心在旅途
    2020-12-09 16:35

    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);
        });
    }
    

提交回复
热议问题