HTML5 - setDragImage only works sometimes?
I have divs wh开发者_C百科ich are set draggable="true" and which have a dragstart handler. In the handle I setDragImage(image, 0, 0); and it usually works. But every fifth time or so I try to drag (and always the first time), it seems like the image isn't loaded and so the browser doesn't setDragImage.
How can I fix this and ensure the image is loaded/used as the drag image everytime? A friend of mine said canvas might help.
Probably image is not loaded in the point you call setDrawImage()
You might want to use an image preloader:
Preloading images with jQuery
精彩评论