Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move raphael set?

I have a set of objects grouped with Raphael.set(). What I want to do is to move the whole set (change x and y coordinates) from one place to another. How I can move the whole set as a single object? What I found already is that when an .attr({X: newX, Y: newY}) is called every element from the set will be positioned on this coordinated which will result in piling all the elements in one place.

like image 235
bozhidarc Avatar asked Jan 13 '12 12:01

bozhidarc


1 Answers

Edit: Refer to Rick Westera's answer as translate is now deprecated.

Use .translate(x, y), example:

var paper = Raphael('stage', 300, 300);
var set = paper.set();
set.push(paper.rect(0,0,30,50));
set.push(paper.circle(40,50,10));
set.push(paper.path("M 0 70 L 100 70"));
set.translate(100, 100);

http://jsfiddle.net/q4vUx/

like image 166
methodofaction Avatar answered Sep 19 '22 13:09

methodofaction