2014-03-05 18 views
2
$("#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/jQuery UI的拖動和排序 - 很難區分

當我從源UL到目標拖了幾箱,他們變得非常難以梳理,試圖移到尤其是當開始。定期排序可以使用相同的CSS。

我知道這是一個常見問題,但沒有一個解決方案在這種特殊情況下工作。

回答

2

您可以更改您的tolerance選項並將其設置爲pointer

指定使用哪種模式測試被移動的物品 是否懸停在另一個物品上。可能的值:

  • 「相交」:該項目與其他項目重疊至少50%。

  • 「指針」:鼠標指針與其他項目重疊。

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

+0

謝謝!這是一個很大的改進。它有時還滯後(即似乎跳過某些位置),但沒有人期望這些東西是完美的。 –