开发者

Is there any way in jQuery draggable drag event to override the top/left position?

开发者 https://www.devze.com 2023-03-13 02:41 出处:网络
What I am attempting to do is enforce my own boundaries since the draggable extension doesnt have the same sort of boundary logic that I need. So i am try开发者_StackOverflow中文版ing to find a way to

What I am attempting to do is enforce my own boundaries since the draggable extension doesnt have the same sort of boundary logic that I need. So i am try开发者_StackOverflow中文版ing to find a way to override the top/left position of the object being dragged if it goes outside of the bounds I enforce. Any ideas?


$(this).draggable({
  drag: function(event, ui) {
    if(ui.position.top>0) { ui.position.top = 0; }
    if(ui.position.left>0) { ui.position.left = 0; }
  }
});
0

精彩评论

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