views:

78

answers:

2

I made a javascript library that lets me drag a marker from a dragzone to one or more dropzones.

The problem is... the mouseup event happens over the marker I'm dragging, no te dropzone.

How can I detect in wich dropzone was the marker dropped, and in wich coordinates?

Here's my script:

http://dl.dropbox.com/u/186012/demos/dragger/drag.html

A: 

This is not actually a direct answer to your question, but why reinvent a solution to this problem that has already been solved in the many popular and robust javascript libs like JQuery.

mP
I tried every solution out there, but the effect I needed was somehow special.I dont want to drag the item I'm clicking on. I need a new instance of a marker to appear and be dragged to it's position on another element, like a map or a canvas.I couldn't do that with any popular library.
Sebastián Grignoli
+1  A: 

if having a new instance is the only special thing you need... you can use the jQuery library to clone your initial clicked upon marker, and drag that clone to where you want it to be.

You can also modify the cloned marker's attributes with jQuery depending on your needs.

Brandon
Yes, that's exactly what I do in the example I posted:http://dl.dropbox.com/u/186012/demos/dragger/drag.htmlThe problem is that I need another special thing: Getting the Id of the element that receives the drop.I'm getting the Id of the dragged element because it's the one below the mouse when the mouseup happens. That's not what I want.
Sebastián Grignoli
I'm starting to suspect that the only way to do this is by calculating the full page coordinates of the mouseup event and start comparing it with the position, size and zIndex of the dropozone elements...
Sebastián Grignoli
I think if you used the keyword "overlap" or "intersect" in your question, I would have got it sooner :) what you are looking for may be here: http://plugins.jquery.com/project/overlaps
Brandon