开发者

Jquery: Draggable bug

开发者 https://www.devze.com 2023-03-26 23:34 出处:网络
My drag element is positioned relative to its parent that is also positioned relative (such positions are a开发者_JAVA技巧 must). I set containment to \'parent\'. When I drag the element and scroll at

My drag element is positioned relative to its parent that is also positioned relative (such positions are a开发者_JAVA技巧 must). I set containment to 'parent'. When I drag the element and scroll at the same time, the drag element goes out of its parent. Is that jQuery's bug? How to fix it? Setting 'scroll' to 'false' does change anything.


I got the same problem but I fixed it by using:

$(window).scroll(function(){
    if( $('#draggable').offset().top < $("#droppable").offset().top)
        $("#draggable").animate({top: 0}, "fast");
});

I use event scroll to check position when scrolling. If the position of the dragged element is less than the drop area, I will set a new position.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号