How do I detect a HTML5 drag event entering and leaving the window, like Gmail does?

后端 未结 12 946
醉话见心
醉话见心 2020-12-13 20:16

I\'d like to be able to highlight the drop area as soon as the cursor carrying a file enters the browser window, exactly the way Gmail does it. But I can\'t make it work, an

12条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 20:31

    Have you noticed that there is a delay before the dropzone disappears in Gmail? My guess is that they have it disappear on a timer (~500ms) that gets reset by dragover or some such event.

    The core of the problem you described is that dragleave is triggered even when you drag into a child element. I'm trying to find a way to detect this, but I don't have an elegantly clean solution yet.

提交回复
热议问题