The HTML5 spec proposes a dropzone attribute although this has not been implemented as yet in any browsers (it seems like Opera did before they switched to WebKit ?). It's format is e.g.
<div dropzone="copy f:image/png">
This means ( I think... ) that the dropzone will "accept", that is - it will cancel the dragover and dragenter events - if the drag contains a file of type image/png. This seems fair enough, you still need to provide a drop handler.
My question is what is the purpose of the "copy" part - the spec. is clear that there must be only one value. How does this relate to dropEffect ? Although also shrouded in mystery and differing browser implementations, the dropEffect is supposed to be used in conjunction with the effectAllowed property, it would go something like this :
- ondragstart - set the dataTransfer.effectAllowed to "copyMove"
- ondragover - set the dataTransfer.dropEffect to "copy" or "move" depending on what you want to do.
Chrome will switch the cursor to indicate a copy or a move will take place based on the dropEffect which can be dynamically set during dragover. The interesting part though is that the dropEffect might be different based on e.g. a key combination used in conjunction with the mouse. How can a dropzone therefore support this use case given that it must only have one "operation" - is this because operation is not the same thing as a "dropEffect" ?
The spec says this ...
The dropzone content attribute's values must not have more than one of the three feedback values (copy, move, and link) specified. If none are specified, the copy value is implied.
..which makes me think it is maybe just for generic mouse cursor feedback ? Chrome and Mozilla both do not allow a drop where dropEffect is not one of the effectAllowed values. One theory is that if you choose to implement dragover and provide a different dropEffect - this would override the operation ? But presumably one of the advantages of using dropzone in the first place is so that you don't have to implement dragover/dragenter and cancel the event etc.
thanks for reading...