开发者

HTML5 - setDragImage only works sometimes?

开发者 https://www.devze.com 2023-04-03 21:25 出处:网络
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 (

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

0

精彩评论

暂无评论...
验证码 换一张
取 消