Re: [whatwg] Proposed addition to Drag and Drop API

2012-07-02 Thread Alex Bain
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?

Thanks,

- Alex 


On Friday, June 29, 2012 at 4:37 PM, Alex Bain wrote:

 @Ryosuke - I do not have a concrete proposal but would be interested in 
 helping to work one out. I had idly considered a content attribute but think 
 that specifying an element (perhaps via a function called setDragElement()) 
 would be a simple implementation.
 
 @Daniel - I had thought that was possible but in my testing I was not able to 
 get it to work. I had tried referencing an existing element as well as 
 creating a new element but neither were visible while dragging [in Chrome].
 
 
 On Friday, June 29, 2012 at 4:30 PM, Daniel Cheng wrote:
 
  Can't you use setDragImage() and pass it the element that holds the post 
  title?
  
  Daniel 
  
  
  On Fri, Jun 29, 2012 at 4:27 PM, Ryosuke Niwa rn...@webkit.org 
  (mailto:rn...@webkit.org) wrote:
   On Fri, Jun 29, 2012 at 4:24 PM, Alex Bain a...@alexba.in 
   (mailto:a...@alexba.in) wrote:
I would prefer not to visually drag the entire post around (which is 
what happens if I set draggable to true on the post container). My goal 
is to set draggable on a container element and only show a small 
element when the user starts dragging.
   
   Ah, that's an interesting use case. Thanks for clarification. Do you have 
   a concrete proposal for this? (e.g. adding new content attribute / 
   element).
   
   - Ryosuke 
   
  
 



Re: [whatwg] Proposed addition to Drag and Drop API

2012-07-02 Thread Daniel Cheng
I tested locally and it works for me--if I set a specific element as the
drag image, it gets used instead of the entire draggable element.

Daniel


On Mon, Jul 2, 2012 at 10:06 AM, Alex Bain a...@alexba.in wrote:

 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?

 Thanks,

 - Alex

 On Friday, June 29, 2012 at 4:37 PM, Alex Bain wrote:

  @Ryosuke - I do not have a concrete proposal but would be interested in
 helping to work one out. I had idly considered a content attribute but
 think that specifying an element (perhaps via a function called
 setDragElement()) would be a simple implementation.

 @Daniel - I had thought that was possible but in my testing I was not able
 to get it to work. I had tried referencing an existing element as well as
 creating a new element but neither were visible while dragging [in Chrome].

 On Friday, June 29, 2012 at 4:30 PM, Daniel Cheng wrote:

 Can't you use setDragImage() and pass it the element that holds the post
 title?

 Daniel


 On Fri, Jun 29, 2012 at 4:27 PM, Ryosuke Niwa rn...@webkit.org wrote:

 On Fri, Jun 29, 2012 at 4:24 PM, Alex Bain a...@alexba.in wrote:

 I would prefer not to visually drag the entire post around (which is what
 happens if I set draggable to true on the post container). My goal is to
 set draggable on a container element and only show a small element when the
 user starts dragging.


 Ah, that's an interesting use case. Thanks for clarification. Do you have
 a concrete proposal for this? (e.g. adding new content attribute / element).

 - Ryosuke







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

2012-07-02 Thread Trevor Burnham
 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

Re: [whatwg] Media queries, viewport dimensions, srcset and picture

2012-07-02 Thread Andy Davies
In Scott Jehl's latest example of a responsive image polyfill
(https://github.com/scottjehl/picturefill), he produced a variation
that allows a non-retinae image to be downloaded by default with the
user having the ability to then choose the download the retina version
of image if then wanted.

Which ever solution to the responsive image eventually get's
incorporated into the spec I think we need to account for this
behaviour at the user-agent level i.e. if the UA decides to download a
non-retina image because the user is on a cell network, then they need
a way of easily choosing to download the retina image if they want.

Any thoughts?

Andy