How to detect the dragleave event in Firefox when dragging outside the window

后端 未结 5 1720
借酒劲吻你
借酒劲吻你 2020-12-04 10:31

Firefox doesn\'t properly trigger the dragleave event when dragging outside of the window:

https://bugzilla.mozilla.org/show_bug.cgi?id=665704

https://bugzil

5条回答
  •  广开言路
    2020-12-04 11:32

    addEvent(document, "mouseout", function(e) {
        e = e ? e : window.event;
        var from = e.relatedTarget || e.toElement;
        if (!from || from.nodeName == "HTML") {
            // stop your drag event here
            // for now we can just use an alert
            alert("left window");
        }
    });
    

    This is copied from How can I detect when the mouse leaves the window?. addEvent is just crossbrowser addEventListener.

提交回复
热议问题