W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2012

Re: [whatwg] Proposed addition to Drag and Drop API (Alex Bain)

From: Trevor Burnham <trevorburnham@gmail.com>
Date: Mon, 2 Jul 2012 17:56:49 -0400
Message-Id: <B11C3036-AF2F-497F-BC20-4B61E16718ED@gmail.com>
To: whatwg@lists.whatwg.org
> 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
Received on Monday, 2 July 2012 21:57:18 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:09 GMT