HTML5 drag & drop behaviour

前端 未结 3 1348
终归单人心
终归单人心 2021-02-13 15:12

I\'m making extensive use of the HTML5 native drag & drop, and it\'s almost entirely behaving itself, with one small exception.

I\'m trying to highlight my dropzones

3条回答
  •  庸人自扰
    2021-02-13 16:01

    I'm genuinely embarrassed by how easy this one was.

    $("*:visible").live('dragenter dragover',function(event){lightdz(event)});
    
    $("#page").live('dragleave dragexit',function(event)
    {
        if(event.pageX == "0")
           dimdz(event);
    });
    
    $("*:visible").live('drop',function(event){dimdz(event)});
    

    #page is a page-wide container. If the dragleave event takes the dragged object outside of the browser window, event.pageX will have a value of 0. If it happens anywhere else, it'll have a non-zero value.

提交回复
热议问题