EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: gultor on August 22, 2012, 08:38:42 AM



Title: How to limit draggable/window movement?
Post by: gultor on August 22, 2012, 08:38:42 AM
Hi All,

Is there any way to limit draggable/window movement only within it's parent?
Specifically, constraint movement just like jqueryui does using containment: "parent" option.

Thanks for your help.


Title: Re: How to limit draggable/window movement?
Post by: stworthy on August 22, 2012, 07:52:36 PM
Set 'inline' property to true to stay inside its parent.


Title: Re: How to limit draggable/window movement?
Post by: gultor on August 22, 2012, 11:19:20 PM
Thanks stworthy for your response.

I tried, but it only hide part of the window if it cross its parent. If the window title is accidentally hidden, then we will lost control and cannot move the window again.
What I want is it never cross the parent, so all the window is visible inside the parent. Is that possible?

Thank you.


Title: Re: How to limit draggable/window movement?
Post by: stworthy on August 23, 2012, 12:28:53 AM
The 'onMove' event fires while the window is being moved. A solution to control the window position is to write some code in 'onMove' event.
Code:
$.extend($.fn.window.defaults, {
onMove: function(left,top){
if (left<0){
$(this).window('move',{
left:0
});;
}
if (top < 0){
$(this).window('move',{
top:0
});;
}
}
});


Title: Re: How to limit draggable/window movement?
Post by: gultor on August 23, 2012, 08:33:20 AM
Thank you very much. It works like a charm  :)