您可以覆蓋被拖動元素的位置。
這小提琴是位置壓倒一切的例子:http://jsfiddle.net/QvRjL/74/
這小提琴是你如何可以做檢查,如果拖動的元素是靠近你的容器的邊界的例子:http://jsfiddle.net/pPn3v/22/
$(document).mousemove(function(e){
window.mouseXPos = e.pageX;
window.mouseYPos = e.pageY;
});
$('[id^="drag-"]').each(function() {
$(this).draggable({
opacity: 0.7,
cursorAt: { top: 15, left: 50 },
scroll: true,
stop: function(){},
drag : function(e,ui){
//Force the helper position
ui.position.left = window.mouseXPos - $(this).draggable('option','cursorAt').left;
ui.position.top = window.mouseYPos- $(this).draggable('option','cursorAt').top;
});
});
你是對的。我做了更多的現場演示,他們可能需要相同的功能,http://jsbin.com/ufarif/7/edit。 – Gajus