开发者

jQuery UI drag-drop large elements

开发者 https://www.devze.com 2023-02-13 01:34 出处:网络
Having a problem with jQuery UI draggable / droppable. Basically, when i drop the item, it doesn\'t drop at the point where the cursor is.

Having a problem with jQuery UI draggable / droppable.

Basically, when i drop the item, it doesn't drop at the point where the cursor is. It seems to drop at maybe the centre of the element I'm dragging, but certainly not the cursor.

Here is the code:

$('.project, .milestone, .todoList, .todoListItem').draggable({ 
    revert:'invalid' 
});

$('.dayWrapper').droppable({ 
    tolerance:'pointer', 
    drop: function(event, ui){ 
        var sch_item = ui.draggable.attr('id'); 
        var sch开发者_JAVA技巧_person = $(this).parent().attr('id'); 
        var sch_date = $(this).attr('id'); 
        addToSchedule(sch_item, sch_person, sch_date) 
    }
});

Thanks in advance


You must be omitting some part of your setup. Using essentially what you've provided, I can make an example that drops the item exactly where I let go of it. You seem to be suggesting that after the drop, it "snaps" somewhere else? As far as I know, unless you have code added to your drop function to do that, it just doesn't do anything.

See here for a simple example taken straight from the jQuery UI examples.


Pretty sure you're looking for the same answer suggested here: JQuery UI : Drop long element at the cursor location instead of the middle of the element

Basically use 'tolerance'.

0

精彩评论

暂无评论...
验证码 换一张
取 消