selecting multiple svg elements and dragging them in Raphael.js

fogy picture fogy · May 1, 2011 · Viewed 9.6k times · Source

Does anyone know how I can achieve this?

I basically have an svg document with multiple shapes,lines,text,etc... and I am trying to implement a selection tool which helps me select multiple elements, group them and drag them.

Answer

thgie picture thgie · May 4, 2011

There is a feature in raphäel called set: http://raphaeljs.com/reference.html#set

You can add all the elements you want to drag around to a new set and then apply the dragging mechanism to the set.

I made you this: http://jsfiddle.net/Wrajf/

It's not perfect. I would add the mousemove event to the document, but for that you need a library like jQuery. Otherwise if you move the mouse to fast you have a fall out.