3 ms·
> There are no less than seven events associated with drag and drop: dragstart, drag, dragover, dragenter, dragleave, drop, and dragend. > This seems rather a
by JoshTriplett 12y ago
> There are no less than seven events associated with drag and drop: dragstart, drag, dragover, dragenter, dragleave, drop, and dragend.
> This seems rather a lot for a series of actions that can be accurately described by the mousedown, mousemove, and mouseup events.
Mouse events also include mouseover, mouseout, mouseenter, and mouseleave.
The start/over/enter/leave events serve useful purposes, notably that you can offer UI cues to the user. For instance, if you drag an image onto an image search page that normally accepts text, the search box can become a giant drop target with "drop image here to search" text. And if you drag a non-image onto the same page, the page can check the MIME type and give the user UI that says that won't work.
- Gracana 12y agoThe author gets into that in "dragthat and dragsomethingelse," where they talk about the problem with dragenter and dragleave behaving like mouseover and mouseout, events which fire many times in situations where you generally don't need them to.
- angersock 12y agoAccording to the bugtracker, took the Firefox folks 4 years (2008-2012) to implement that. Read the rest of the article: there's a lot of other stupid API shit that heavily outweighs any clever little benefits.
- mrec 12y ago> Mouse events also include mouseover, mouseout, mouseenter, and mouseleave Not to mention onclick and ondblclick, which really needs access to the OS-level double-click delay setting if you want it to behave properly.