JQuery UI:将长元素拖放到光标位置而不是元素的中间位置

sde*_*ont 32 jquery drag-and-drop jquery-ui jquery-ui-draggable

我有一些非常长的可拖动元素,我可以放在背景表的所有单元格中.

当我开始拖动这种元素悬停我的droppable容器(我的表的单元格)时,知道元素将被丢弃的"热点"是它自身的中间部分.

不幸的是,我的元素中间通常是不可见的,将元素放在正确的位置是没有用的.

是否可以指定光标位置来选择元素将放在哪个容器中而不是元素的中间?

我真的被困住了,我真的很感激任何帮助.

嗨,这是一个描述我的问题的示例代码.黄色div不能轻易落入细胞,因为它太长了.jsbin.com/upunek/edit

谢谢

Jam*_*gne 55

我想你要找的是tolerance.我可能建议使用,"pointer"因为这将使用鼠标光标作为"重叠"点.

http://jqueryui.com/demos/droppable/

$('[id^="cell-"]').each(function(index) {
  $(this).droppable({
  accept: ".cartridge",
  hoverClass: "cell-highlght",
    tolerance: "pointer",
  drop: function( event, ui ) {
    $( this ).addClass( "cell-dropped" );
  }
  });
}); 
Run Code Online (Sandbox Code Playgroud)

http://jsbin.com/upunek/2/edit