最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to animate 'Raphael' canvas? - Stack Overflow

programmeradmin0浏览0评论

I'm using the Raphael library to create SVG objects.

To initialise the SVG shape and create a canvas for everything inside, I've used the following line as stated in the documentation:

var paper = Raphael(10, 50, 320, 200);

I now want to animate the paper and everything inside it, just like I would animate a shape which had been appended to the paper in the following maner:

var firstShape = paper.rect(x, y, width, height);
firstShape.animate({x: 100}, 500, "<");

When I try something similar with the paper such as:

paper.animate({x: 100}, 500, "<");

I get the error 'paper.animate is not a function'.

What's happening here, and how can I get around it?

I'm using the Raphael library to create SVG objects.

To initialise the SVG shape and create a canvas for everything inside, I've used the following line as stated in the documentation:

var paper = Raphael(10, 50, 320, 200);

I now want to animate the paper and everything inside it, just like I would animate a shape which had been appended to the paper in the following maner:

var firstShape = paper.rect(x, y, width, height);
firstShape.animate({x: 100}, 500, "<");

When I try something similar with the paper such as:

paper.animate({x: 100}, 500, "<");

I get the error 'paper.animate is not a function'.

What's happening here, and how can I get around it?

Share Improve this question edited Jun 29, 2010 at 10:11 Jack Roscoe asked Jun 29, 2010 at 10:03 Jack RoscoeJack Roscoe 4,34310 gold badges38 silver badges46 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9

You can’t animate paper object. Paper has no attributes to animate. But you could unite all your elements into set and then animate it.

Your closing bracket sequence is wrong

Change

paper.animate({x: 100, 500, "<")}; 

to

paper.animate({x: 100}, 500, "<"); 

UPDATE

From the docs, it does not seem that animate can be called directly on paper, but only on a sub-shape cut out of the canvas - that is why firstshape.animate works

You can not animate the drawing board... only the shapes inside it ..

paper is your drawing board.. whereas firstShape is a shape created inside the board ..

发布评论

评论列表(0)

  1. 暂无评论