2010-05-05 102 views
9

我正在使用jQuery sortable插件(2連接列表),並有一個奇怪的錯誤。當你拖動圖片鼠標拖動的項目上面jquery sortable stange mouse offset

截圖:http://img408.imageshack.us/i/mouseb.png/

的HTML列表的一個

<ul class="flickr_key_ul ui-sortable">  
      <li><img style="display: inline;" src="http://farm3.static.flickr.com/1039/548804108_a8816f42f5_s.jpg" alt="Up the Ginnel" title="Up the Ginnel" class="flickr_image"></li> 
      <li><img style="display: inline;" src="http://farm3.static.flickr.com/1116/548804090_7e625a461b_s.jpg" alt="Down the Ginnel" title="Down the Ginnel" class="flickr_image"></li> 
      <li><img style="display: inline;" src="http://farm3.static.flickr.com/1011/548804074_75f2c0bd0e_s.jpg" alt="Entering the Ginnel" title="Entering the Ginnel" class="flickr_image"></li> 
      <li><img style="display: inline;" src="http://farm3.static.flickr.com/1345/548804064_6023b070a7_s.jpg" alt="Up Bachelor Lane" title="Up Bachelor Lane" class="flickr_image"></li> 

      <li><img style="display: inline;" src="http://farm3.static.flickr.com/1183/548804020_3116d900ce_s.jpg" alt="Down Bachelor Lane" title="Down Bachelor Lane" class="flickr_image"></li> 
      <li><img style="display: none;" src="http://farm3.static.flickr.com/1325/548771897_0a32a6492a_s.jpg" alt="Flower" title="Flower" class="flickr_image"></li> 
      <li><img style="display: none;" src="http://farm3.static.flickr.com/1411/548771891_e37de6bcc0_s.jpg" alt="Steps" title="Steps" class="flickr_image"></li> 
      <li><img style="display: none;" src="http://farm3.static.flickr.com/1424/548771883_23a4909300_s.jpg" alt="Hopwood Bridle Way" title="Hopwood Bridle Way" class="flickr_image"></li> 
      <li><img style="display: none;" src="http://farm3.static.flickr.com/1350/548771867_beaf20476b_s.jpg" alt="Cat, Sleeping" title="Cat, Sleeping" class="flickr_image"></li> 
      <li><img style="display: none;" src="http://farm3.static.flickr.com/1393/548771853_af19a5dac2_s.jpg" alt="Road Cones, Hiding" title="Road Cones, Hiding" class="flickr_image"></li> 
    </ul> 

排序配置:

horizontal: { 
      helper: "clone", // Instead of dragging the real image a copy will be dragged 
      connectWith: ["#flickr_sidebar ul"], // To be able to drag and drop an image to another image gallery they need to be connected 
      cursor: 'pointer', //change the cursor when dragging 
      appendTo: 'body', //When dropped the images need to be appended to the image gallery where they are dropped 
      containment: rootel, //Make sure the user can't drag the images outside the widget 
      revert: true, // if the user releases the image ouside the dropbox it'll return to it's original position 
      zIndex: 9999 
     }, 

任何人都知道如何讓鼠標在中間或什麼? (cursorAt不工作)

+0

我有類似的問題,但拖動產品之上鼠標的偏移。 – cometta 2011-01-13 16:45:11

回答

20

我曾與鼠標指針偏移同樣的問題從{浮動:左}變更左對齊時{顯示:內聯}。解決的辦法是:

cursorAt: { top: 0, left: 0 } 

這同時適用於可排序和可拖動:

$("#someid").draggable({cursorAt: { top: 0, left: 0 },...}) 
$("#someid").sortable({cursorAt: { top: 0, left: 0 },...}) 
+0

只想感謝你!我遇到了這個問題,你的修復工作就像一個魅力! – Bryan 2012-06-23 03:30:20

+0

它可以鏈接列表嗎? – GRGodoi 2013-01-23 19:33:32

+0

簡單,briliant =) – M05Pr1mty 2013-03-22 15:45:31

4

嘗試此

horizontal: { 
     helper: "clone", // Instead of dragging the real image a copy will be dragged 
     connectWith: ["#flickr_sidebar ul"], // To be able to drag and drop an image to another image gallery they need to be connected 
     cursor: 'pointer', //change the cursor when dragging 
     cursorAt: { cursor: "move", top: 6, left: 275 }, 
     appendTo: 'body', //When dropped the images need to be appended to the image gallery where they are dropped 
     containment: rootel, //Make sure the user can't drag the images outside the widget 
     revert: true, // if the user releases the image ouside the dropbox it'll return to it's original position 
     zIndex: 9999 
    }, 
+0

有類似的問題。 appendTo:'body'解決了它。 – 2014-03-18 15:35:35