【问题标题】:Raphael.js - Run function after animation, while passing parametersRaphael.js - 动画后运行函数,同时传递参数
【发布时间】:2017-11-10 22:02:42
【问题描述】:
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次,因为目前它只运行一次并停止。

【问题讨论】:

    标签: javascript raphael


    【解决方案1】:

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

    例如,试试

    test.bind(null,Num+1) 
    

    用于回调函数而不是 test(Num+1)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-26
      • 1970-01-01
      • 2022-08-14
      • 1970-01-01
      • 2015-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多