how to call raphael methods on jquery objects?

前端 未结 2 1506
被撕碎了的回忆
被撕碎了的回忆 2021-01-03 14:22

I\'m creating some circles using Raphael. When a user clicks a button, I want to animate these circles (by growing their radius). How do I do this?

For example, here

2条回答
  •  猫巷女王i
    2021-01-03 15:02

    Your selector "circle" isn't targeting anything - there's no circle element for you to target. However, you could do this:

    circle1 = paper.circle(50, 75, 30); 
    circle2 = paper.circle(150, 75, 30); 
    
    $("button").click(function() { 
        circle1.animate({ r: 100 }, 500);
        circle2.animate({ r: 100 }, 500);
    }); 
    

    I couldn't tell you if you can animate() the circles based on the radius, but at the very least this gives you a jQuery object to work with.

提交回复
热议问题