EasyUI Forum
May 15, 2024, 04:21:09 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Child window position limit (constrained) as default behavior  (Read 11519 times)
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« on: October 29, 2015, 08:24:28 PM »

i saw this 3 years old question
http://www.jeasyui.com/forum/index.php?topic=603.0
about How to limit draggable/window movement

but i see this problem solution still not implemented as default behavior of easyui window if the properti inline:true
see this fiddle: http://jsfiddle.net/hocu4Lwp/2/



can you make this as default behavior?

thank you in advance
« Last Edit: October 29, 2015, 09:00:07 PM by aswzen » Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: October 30, 2015, 01:03:59 AM »

The extended method 'constrain' method can be used to prevent the window from moving out of its parent container.
Code:
$.extend($.fn.window.methods, {
constrain: function(jq){
return jq.each(function(){
var target = this;
var state = $(target).data('window');
$(target).window('window').draggable({
onDrag: function(e){
var d = e.data;
if (d.left < 0){d.left = 0;}
if (d.top < 0){d.top = 0;}
var parent = state.options.inline ? $(d.parent) : $(window);
if (d.left + $(d.target).outerWidth() > parent.width()){
d.left = parent.width() - $(d.target).outerWidth();
}
if (d.top + $(d.target).outerHeight() > parent.height()){
d.top = parent.height() - $(d.target).outerHeight();
}

state.proxy.css({
display:'block',
left: e.data.left,
top: e.data.top
});

return false;
}
})
})
}
})

Please refer to http://jsfiddle.net/hocu4Lwp/3/
Logged
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #2 on: October 30, 2015, 01:26:21 AM »

absolutely thankyou jarry.. Smiley
谢谢

please make it to easyui default behaviour if you consider
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
arma
Full Member
***
Posts: 110


View Profile
« Reply #3 on: November 08, 2015, 03:17:49 PM »

It's for window only not applied to dialog isn't it ?
I replace the window to dialog and it works good.

Code:
$.extend($.fn.dialog.methods, {
    constrain: function (jq) {
        return jq.each(function () {
            var target = this;
            var state = $(target).data('window');
            $(target).dialog('dialog').draggable({
....
« Last Edit: November 08, 2015, 03:39:05 PM by arma » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!