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

后端 未结 5 1712
借酒劲吻你
借酒劲吻你 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

    only solution that has worked for me and took me a few goes hope this helps someone!

    note when cloning you need to deepclone with events and data:

    HTML:

    Child element still works!

    jQuery

    $('.dropbox').each(function(idx, el){
        $(this).data("counter" , 0);
    });
    
    $('.dropbox').clone(true,true).appendTo($('body');
    
    $('dropbox').on({
        dragenter : function(e){
            $(this).data().counter++;
            
        },
          dragleave: function(e){
    
            $(this).data().counter--;
    
             if($(this).data().counter === 0)
                  
        }
    });
    

提交回复
热议问题