tomen
tomen

Reputation: 539

Raphael- Detect overlapped elements when drag and drop

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?

Upvotes: 1

Views: 3307

Answers (1)

user56reinstatemonica8
user56reinstatemonica8

Reputation: 34104

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

Upvotes: 2

Related Questions