【问题标题】:Js Raphael object.animate call doesn't workJs Raphael object.animate 调用不起作用
【发布时间】:2020-10-27 01:55:49
【问题描述】:

您好,我是 Js 新手,我正在使用 Raphael 库进行一些简单的对象移动,但我的一个函数不起作用,即使它应该起作用。

以下是部分代码:

/*Moving Objects*/
    var mainBall = paper.circle(650,340,30);

    var mainRect = paper.rect(430,310, 50,50);

    
    /*Moving Object attributes*/
    mainBall.attr({fill:"45-purple-yellow"});

    mainRect.attr({fill:"45-purple-yellow"});

和功能

function leavePipeB1(){

        mainBall.animate({cx:550, cy:340}, 1200, "linear", ball1ToMagnet);

    }

    function ball1ToMagnet(){

        mainBall.animate({cx:130, cy:115}, 1300, "elastic", showRect);

    }

    function leavePipeR1(){

        mainRect.animate({cx:550, cy:340}, 1200, "linear");

    }

    function hideBall(){

        tempBall.hide();
    }

    function hideRect(){

        tempRect.hide();
    }

    function hideEll(){

        tempEll.hide();
    }

    function showRect(){

        tempRect.show();
    }

我这样称呼他们:

    hideRect();

    hideEll();

    leavePipeB1();

    hideBall();

    leavePipeR1();

但是 leavePipeR1() 不起作用。

有什么办法可以解决这个问题?

【问题讨论】:

    标签: javascript raphael


    【解决方案1】:

    这是因为 Rect 没有 cx,cy 属性。将它们替换为 x,y。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-28
      相关资源
      最近更新 更多