[whatwg] How to tell when a drag and drop was successful?

Ian Hickson ian at hixie.ch
Tue Aug 13 12:56:28 PDT 2013


On Tue, 13 Aug 2013, Daniel Trebbien wrote:
>
> Reading through the spec, I am not seeing how an application can 
> determine whether a drop into a different window was successful.

This was an error in the spec. Good catch.

I've updated the spec. The trick is to check event.dataTransfer.dropEffect 
in the dragend event; if it's "none" then the drag was canceled.

This works already in Chrome and Firefox for same-page drags; it also 
works in Chrome for cross-app drags, but in Firefox for some reason you 
always get "none" for cross-app drags currently. It does work for 
cross-page (all within Firefox) drags in Firefox. (Tested on Mac.)


> The spec gives an example of removing the dragged element from the 
> display: 
> http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#introduction-8 
> .. but this has the problem that the element is removed regardless of 
> whether the drop was successful, right?

Good point. Fixed. Thanks!

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list