How to animate Raphael's canvas?

I am using the Raphael library to create SVG objects.

To initialize the SVG form and create a canvas for everything inside, I used the following line, as indicated in the documentation:

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

Now I want to animate the paper and everything inside, just as I would animate the form that was added to the article in the following manner:

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

When I try something similar with paper, for example:

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

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

What is going on here and how can I get around it?

+3
source share
3 answers

Incorrect sequence of your brackets

Edit

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

to

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

UPDATE

, animate paper, - - firstshape.animate

+3

. . set, .

+9

You cannot animate a drawing board ... only the shapes inside it.

Paper is your drawing board, while firstShape is a shape created inside the board.

0
source

Source: https://habr.com/ru/post/1752246/


All Articles