I spent this day on a fun problem - I have some canvases that I would like to drag using my own HTML5 drag and drop features. Everything works fine, except in the end I found that in Chrome 28.0.1500.95, the default ghost image for the canvas is not displayed if the canvas is a child of the inline div block. Check out this minimal working example:
<html> <body> <div style='display:inline-block'> <canvas id='canvas1' width='100px' height='100px' draggable='true'></canvas> </div> <div> <canvas id='canvas2' width='100px' height='100px' draggable='true'></canvas> </div> <script type="text/JavaScript"> var canvas1, canvas2, context1, context2; canvas1 = document.getElementById('canvas1'); context1 = canvas1.getContext('2d'); canvas2 = document.getElementById('canvas2'); context2 = canvas2.getContext('2d'); context1.fillText('no drag', 10, 30); context2.fillText('yes drag', 10, 30); </script> </body> </html>
When you try to drag "yes and drag", a ghostly image appears, but not for "no drag." However, if I also adhere to the target, I can challenge it by dropping “no resistance” on it, as usual, despite the missing ghost. I would like to understand why the ghost image disappears, apparently, based on the CSS of the parent, or if something else happens here - thanks in advance!
source share