Raphael.js - 运行 动画后的函数,同时传递参数

Raphael.js - Run function after animation, while passing parameters

test(0);

function test(Num){ 
    if (Num<6){
        ball.attr({ cy:520 , cx:900});
        ball.animate({cy: 520 , cx: 400}, speed, test(Num+1));  
    }else{
        //something
    }           
}

我使用 Raphael Javascript 框架编写了这段代码,但无法将其回调。特别是测试(Num + 1),我如何将参数传回,以便该函数将重复 x 次,因为目前它只运行一次并停止。

您需要为回调函数绑定一个参数。而不是执行回调函数(除非它 returns 一个函数本身)。

例如,尝试

test.bind(null,Num+1) 

回调函数代替test(Num+1)。