[whatwg] Proposed addition to Drag and Drop API (Alex Bain)
Trevor Burnham
trevorburnham at gmail.com
Mon Jul 2 14:56:49 PDT 2012
> I did a bit of reading about what the WhatWG spec says setDragImage should do and wanted to ensure I understand what the spec is saying and how Webkit is behaving.
>
> Spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dom-datatransfer-setdragimage
>
> The spec says defines "setDragImage" as: setDragImage(element, x, y)
>
> Element argument is defined as: "If the element argument is an img element, then set the drag data store bitmap to the element's image (at its intrinsic size); otherwise, set the drag data store bitmap to an image generated from the given element (the exact mechanism for doing so is not currently specified)."
>
> This says, if I'm understanding it correctly, that I can provide any element as the first argument and a bitmap image will be generated as a drag image. This would allow me to accomplish what I'm trying to do (setting a small drag element to represent a larger draggable container). However, in my testing, Webkit will not render anything unless the element specified is an image.
>
> Am I misunderstanding the spec, or might this be a bug in the implementation?
I can't say which without an example of how you're using setDragImage, but I assure you that it works with non-img elements in WebKit browsers: http://jsfiddle.net/mZGP7/1/
Note, however, that (at least for WebKit-based browsers) the element must be in the document body, and it can't have visibility: hidden or display: none or even positioning that puts it outside of the window bounds. None of this is dictated by the spec, which simply declares that the mechanism for turning an element into a bitmap is unspecified.
At this point, I would take your questions to StackOverflow rather than the WHATWG list (unless you would like to draft a proposal for making the setDragImage spec more precise).
Best,
Trevor
More information about the whatwg
mailing list