title: HTML5 Drag and Drop effectAllowed and dropEffect
body: <p>The relationship between these two properties seems to have been the source of some confusion.  Based on reading both <a href="https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer" rel="noreferrer">the MDN site</a> and <a href="http://msdn.microsoft.com/en-us/library/ie/ms533743%28v=vs.85%29.aspx" rel="noreferrer">MSDN</a> I thought i had figured it out, but now I am not sure...</p>
  <p>I figured that when an element is dragged, you can specify what is allowed to happen to it (i.e. it can be moved, copied, linked to - one of the <code>effectAllowed</code> constants). This is the <code>effectAllowed</code> property.</p>
  <p>Different drop targets do different things, so when you dragover another element it can control which &quot;effect&quot; takes place on the drop, this is the &quot;dropEffect&quot; property. So I set up a simple example to test this theory out.</p>
  <p><a href="http://jsfiddle.net/stevendwood/3sAYn/2/" rel="noreferrer">JSFiddle</a></p>
  <pre><code>$(&quot;[draggable='true']&quot;).on(&quot;dragstart&quot;, function(e) {
      var dt =  e.originalEvent.dataTransfer;
      dt.effectAllowed = &quot;copyMove&quot;;
      dt.setData(&quot;text/plain&quot;, &quot;Foo&quot;);
  });
  
  $(&quot;#dropZoneCopy&quot;).on(&quot;dragover&quot;, function(e) {
      var dt =  e.originalEvent.dataTransfer;
      dt.dropEffect = &quot;copy&quot;;
      e.preventDefault();
  });
  
  $(&quot;#dropZoneMove&quot;).on(&quot;dragover&quot;, function(e) {
      var dt =  e.originalEvent.dataTransfer;
      dt.dropEffect = &quot;move&quot;;
      e.preventDefault();
  });
  </code></pre>
  <p>I have a box the user can drag - the effects allowed are &quot;copyMove&quot;. I have one box that sets <code>dropEffect</code> to copy, and once that sets <code>dropEffect</code> to move.  What I expect is that when the user drags over the &quot;copy box&quot; the cursor will change to indicate a copy will happen, as I drag over the &quot;move box&quot; the cursor changes to indicate a move...</p>
  <p>Only Chrome behaves as I would expect.  Is this because the other browser are wrong or because I don't understand the spec. properly ?</p>
  <p><strong>UPDATE</strong>
  Some more information from fiddling with this.</p>
  <p>In both Firefox and Chrome, if you have a dragsource which indicates the effectAllowed is &quot;copy&quot; and a dropzone that says dropEffect is &quot;move&quot; then you cannot drop on the drop zone even if you cancel the event. I thought that dropEffect would be useful to read ondrop to see what to do, but it isn't available on Chrome, the dropEffect does not appear on the drop handler, e.g. trying to read the dataTransfer.dropEffect will say that the dropEffect is &quot;none&quot; even though you set it on dragover.  Setting the dropEffect as noted above does influence the way the cursor is displayed.</p>
  <p>On Firefox, the dropEffect does come through on the dropzone after being set on dragover, but it does <em>not</em> influence the display of the mouse cursor. On Firefox windows pressing the ctrl key does affect the display of the mouse, but does not affect the dropEffect property.</p>
  <p>The spec shows that the source can listen for the dragend event to see what happened. It should look at the dropEffect within this event. Chrome, Mozilla and Safari work as you would hope here, the drop effect appears in the dragend event. In IE if the effect allowed is a simple value e.g. &quot;copy&quot; then any succesfull drop results in this value appearing as the dropEffect on dragend. If the effectAllowed was a compound value like copyMove and you tried to select &quot;move&quot; on dragover by setting the dropEffect, you're out of luck, that will come through as dropEffect = &quot;none&quot; at the source on dragend. You are stuck with one cursor &amp; one dropEffect and that is the effectAllowed set on dragstart if that effect is a simple value. Interestingly the dropEffect it seems does come through when you drag into a native application from IE11 at least (and i assume earlier).</p>
  <p>Other notes</p>
  <p>On Safari on a mac - effectAllowed cannot be set programatically, therefore any dropEffect that gets set is valid. When you press the cmd key the effectAllowed becomes &quot;move&quot; and when you press the alt key the effectAllowed becomes &quot;copy&quot;. Thereafter it works as you would hope, if the dropEffect is not one of these effectAlloweds the drop is not allowed by the browser.</p>
  <p><strong>More Info</strong>
  I've been spending some spare time working on an HTML5 drag and drop library i wrote a bunch more about this and other issues in the docs for it, if you're interested please take a look at
  <a href="https://github.com/stevendwood/html5-dropzone" rel="noreferrer" title="HTML5 Dropzone">the project</a></p>