1

I'm trying to get element by drag and drop another element. I have for example 2 circles: c1 and c2. What i want to do is : if i drop c2 above c1 hence they are overlapped(not entirely necessary), i can get circle c1 (ex:id, title... etc).

http://jsfiddle.net/Tomen/LYjnV/1/

Is there a way to do it?

tomen
  • 539
  • 7
  • 20
  • 1
    [Element.onDragOver](http://raphaeljs.com/reference.html#Element.onDragOver) might be useful, if all you need to do is perform some action based on the dragged over element. – oli Jan 18 '12 at 06:21
  • It's the other way, onDragOver(f) can only run function on my current element when it was dropped on other element. But what i want is that under element. – tomen Jan 18 '12 at 18:04

1 Answers1

2

I'm not sure if you want the moving element that collides, or the static one that is collided with - so I'll give both. (it sounds like you want the static one, but it is this one which Element.onDragOver gives, as suggested in Oli's comment)

Here is a rudimentary jsfiddle which accesses both elements:

It's possible Raphael already has a feature like this for accessing the dragged element, but if it does I haven't managed to find it looking in the docs, code or DOM.

My implementation of the second point is an extremely basic demonstration which would need improvement. For something more complete, I'd recommend reading and taking inspiration from the code used by the heavily tested and refined jQuery UI to do the same thing

Community
  • 1
  • 1
user56reinstatemonica8
  • 32,576
  • 21
  • 101
  • 125