简体   繁体   English

Js Raphael object.animate 调用不起作用

[英]Js Raphael object.animate call doesn't work

Hi I'm new to Js and I'm doing some simple moving of object with the Raphael library, but one of my functions doesn't work, even though it should.嗨,我是 Js 新手,我正在使用 Raphael 库进行一些简单的对象移动,但是我的一个函数不起作用,即使它应该起作用。

Here's some of the code:这是一些代码:

/*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"});

and the functions和功能

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

I call them like this:我这样称呼他们:

    hideRect();

    hideEll();

    leavePipeB1();

    hideBall();

    leavePipeR1();

But leavePipeR1() doesn't work.但是 leavePipeR1() 不起作用。

Any way I could fix this?我有什么办法可以解决这个问题?

This is because a Rect doesn't have a cx,cy property.这是因为 Rect 没有 cx,cy 属性。 Swap those for x,y instead.将它们交换为 x,y。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM