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

后端 未结 12 937
醉话见心
醉话见心 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

    Don't know it this works for all cases but in my case it worked very well

    $('body').bind("dragleave", function(e) {
       if (!e.originalEvent.clientX && !e.originalEvent.clientY) {
          //outside body / window
       }
    });

提交回复
热议问题