I’m currently coding HTML5 drag and drop. On a certain area I’m looking to have it’s drag image set as a trash icon, and when the mouse is over a draggable area to have non-specific image. I have the events down and logic working for that, however it doesn’t appear as though the setDragImage() function may only be available on the dragstart function. Is this really the only event you can assign the setDragImage() at? I’ve looked through the spec and it doesn’t seem to say either way.
Share
This is the relevant part within the Firefox codebase that shows that the DataTransfer object (which holds the drag image) is set to readonly after dragstart.
https://mxr.mozilla.org/mozilla-central/source/content/events/src/nsEventStateManager.cpp#2141
And here is the setDragImage method which shows that it checks for readonly before allowing the image to be set.
https://mxr.mozilla.org/mozilla-central/source/content/events/src/nsDOMDataTransfer.cpp#581
From the above code, it shows that the drag image can only be updated within the dragstart event in Gecko.