私は Jquery ui を使用しており、ドラッグ可能なコンテンツを作成する機能を提供しています。ドラッグ可能なアイテムをボックス内で強制的に移動させるオプション「containment」があります。
ただし、私の場合、コンテンツ (画像) は画面を超える必要があります。画面内にドラッグしないようにするにはどうすればよいですか?
ありがとう
$("#popup").draggable({
addClasses:true,
scrollSpeed: "200",
containment: "parent",
//appendTo: "body",
helper: function(){
// Create an invisible div as the helper. It will move and
// follow the cursor as usual.
return $('<div></div>').css('opacity',0);
},
drag: function(event, ui){
// During dragging, animate the original object to
// follow the invisible helper with custom easing.
var p = ui.helper.position();
$(this).stop().animate({
top: p.top,
left: p.left
},1000,'easeOutCirc');
}
});