从可排序文件中拖出来

Drag out of a sortable

本文关键字:文件 排序      更新时间:2023-12-25

站点:http://ace.brianhare.com/test/

我想要它,这样卡片就可以拖到屏幕底部(玩家的手牌)。现在这个功能可以工作,但一旦它在玩家手中,就不能从手中拖出来。

我希望卡片能够被拖到桌子上,然后可以自由拖动。如何将卡片从手中自由地拖回桌子?一旦一张牌被拖到手上,它就不会动了。

看看这个插件(尤其是演示)。我想这会对你有所帮助。http://rubaxa.github.io/Sortable/

我终于得到了我想要的:

$('*:not(:input)').disableSelection();
$(".sortable").sortable({
    connectWith: '.sortable, .droppable',
    beforeStop: function (event, ui) {
        ui.item.css('position', 'relative');
    }
});
$(".droppable").droppable({
    tolerance: "fit",
    drop: function (ev, ui) {
        if(ui.draggable.hasClass('ui-sortable-helper')) {
            var clone = ui.draggable.clone();
            ui.draggable.remove();
            $(this).append(clone);
            $(clone).draggable({
                connectToSortable: '.sortable'
            });
        }

    }
});

$('.draggable').draggable({
    connectToSortable: '.sortable'
});

演示:http://jsfiddle.net/nfuza42k/