开发者

How to get the position of the preview of a draggable element when it's dropped in HTML5 DnD

I'm doing a visual editor using HTML5 Drag and Drop and i need to drag an el开发者_如何学运维ement set as draggable to a div who acts as a container.

Some browsers provides a kind of preview image that represents the element while i'm dragging it, and when i let the element in the container with the drop event, i need to get the position where the user wants to put him. The problem is that i don't know the position of the preview ghost provided by browsers, so i don't know where exactly the element should be positioned.

I used the mouse position but it's not what i wanted, because the mouse position is not ever the same as the preview's. Is there a way to get the current position of the preview of a dragging element?


Have you considered using jQuery UI to do your DnD? I'm not sure if you've considered that or not, but here are some resources that might help you in-case you do choose to do the jQuery UI route:

jQuery UI Draggable (also see Droppable)

jquery ui drag/drop getting position from multiple draggables

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜