【问题标题】:jQuery UI draggable and sortable - hard to sortjQuery UI 可拖动和可排序 - 难以排序
【发布时间】:2014-03-05 14:07:32
【问题描述】:
$("#source li").draggable({
    appendTo: "#destination",
    helper: "clone",
    connectToSortable: "#destination",
    containment: "document"
});

$("#destination").sortable({
    items: "li:not(.placeholder)",
    connectWith: "li",
    placeholder: "dragging-placeholder",
    sort: function() {
        $(this).removeClass("ui-state-default");
    },
    over: function() {
        $(".placeholder").hide();
    },
    out: function() {
        if ($(this).children(":not(.placeholder)").length === 0) {
            $(".placeholder").show();
        }
    }
});

JSFiddle:http://jsfiddle.net/j9FK5/7/

当我将几个框从源 UL 拖到目标时,它们变得非常难以排序,尤其是在尝试移动到开头时。常规排序适用于相同的 CSS。

我知道这是一个常见问题,但没有一种解决方案在这种特殊情况下有效。

【问题讨论】:

    标签: jquery-ui jquery-ui-sortable jquery-ui-draggable


    【解决方案1】:

    您可以更改tolerance 选项并将其设置为pointer。

    指定使用哪种模式来测试项目是否被移动 悬停在另一个项目上。可能的值:

    • “intersect”:该项与其他项重叠至少 50%。

    • “pointer”:鼠标指针与其他项目重叠。

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

    【讨论】:

    • 谢谢!这是一个很大的进步。它有时仍然滞后(即似乎跳过了一些位置),但没有人期望这些事情是完美的。
    猜你喜欢
    • 2011-12-11
    • 2012-06-23
    • 1970-01-01
    • 2013-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-02
    • 1970-01-01
    相关资源
    最近更新 更多