1

我正在使用 Jquery ui,它为我提供了制作可拖动内容的功能。它有一个“包含”选项,可以强制可拖动项目在框内移动。

但是,就我而言,内容(图像)必须超出屏幕,我怎么能强制它不要在屏幕内拖动?

谢谢

$("#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');
    }
});
4

0 回答 0