Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Drag-and-Drop Flickering on Hover (Webkit only)
    primarykey
    data
    text
    <h2>Issue</h2> <p>I've just finished implementing a feature in which users can drag files into the browser and drop upon a supporting File Upload plugin, which processes the drop.</p> <p>However, in order to give users a hint that they can even drop things in the first place, I've implemented a <code>dragover</code> event to show a <code>div</code> that says something akin to "Drop Here". This, in turn, hides the <code>div</code> which has the "Choose File..." button, and replaces it, until the user stops dragging.</p> <p>But it seems, when I implement this, dragging over the target area is causing flickering. To be clear:</p> <ul> <li><code>div</code> with "Choose File" interface is shown.</li> <li>Item dragged (or selected text dragged); "Drop here" is shown.</li> <li>Item dragged over the "Drop here" area; flickering begins.</li> </ul> <p>Additionally:</p> <ul> <li>There is no issue in Opera 12 or Firefox 16.</li> <li>The issue is blatantly obvious in Chrome 23 and Safari 5.</li> <li>The issue is partly there in IE 9 (IE 10 untested); it flickers for about 5 seconds, then stops.</li> </ul> <h2><a href="http://jsfiddle.net/ezCEG/" rel="noreferrer">jsFiddle</a></h2> <p><em>(Warning: the fiddle is very crude.)</em></p> <p>Just select some of the text and drag it over the blue box and you will see what happens; it will be obvious the behavior it should not be exhibiting.</p> <h3>Code used in fiddle</h3> <pre><code>var $dropTarget = $("#container"); $(document).bind("dragover", function(e) { if ($dropTarget.hasClass("highlight")) return; $dropTarget.addClass("highlight"); $dropTarget.find("[name='drop']").show(); $dropTarget.find("[name='drag']").hide(); }).bind("dragleave drop", function(e) { if (!$dropTarget.hasClass("highlight")) return; $dropTarget.removeClass("highlight"); $dropTarget.find("[name='drop']").hide(); $dropTarget.find("[name='drag']").show(); });​ </code></pre> <h2>My solution...?</h2> <p>To be honest, I've got no idea of what to try. There is not extensive documentation on the behavior of <code>dragover</code> or <code>dragleave</code>, and I don't even know why this is happening, so I can't even begin to debug it. I feel like <code>dragover</code> should only fire once, but even dragging around the screen just fires it over and over and over again.</p> <p>I've looked at Google Images and Google Contacts for their drag-and-drop behavior, but their code is completely minified and unreadable, and I can't even find any specified "drag" behavior.</p> <p>So, is there some fix to this seemingly odd behavior? If this is a bug in WebKit, which I suspect, is there some brilliant workaround and/or hack I can use?</p> <p>Thanks to everyone for their time!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload