aboutsummaryrefslogtreecommitdiffstats
path: root/ui/resizable.js
diff options
context:
space:
mode:
authorJyoti Deka <dekajp@gmail.com>2014-08-04 07:29:11 -0400
committerMike Sherov <mike.sherov@gmail.com>2014-08-04 10:04:50 -0400
commit750a8fd0c267aaba784f6dc76924619dbb459762 (patch)
treec9f566eac31c2615c753154ab56878ec27aa5d69 /ui/resizable.js
parent2779212a0e6e34fdea3f0d442e4d92218ac943fa (diff)
downloadjquery-ui-750a8fd0c267aaba784f6dc76924619dbb459762.tar.gz
jquery-ui-750a8fd0c267aaba784f6dc76924619dbb459762.zip
Resizable: Fix containment width with relative parent.
Refs #10140 Closes gh-1303
Diffstat (limited to 'ui/resizable.js')
-rw-r--r--ui/resizable.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/ui/resizable.js b/ui/resizable.js
index 8c65a12c8..0906da6fe 100644
--- a/ui/resizable.js
+++ b/ui/resizable.js
@@ -774,7 +774,7 @@ $.ui.plugin.add( "resizable", "containment", {
},
resize: function( event ) {
- var woset, hoset,
+ var woset, hoset, isParent, isOffsetRelative,
that = $( this ).resizable( "instance" ),
o = that.options,
co = that.containerOffset,
@@ -809,11 +809,19 @@ $.ui.plugin.add( "resizable", "containment", {
that.position.top = that._helper ? co.top : 0;
}
- that.offset.left = that.parentData.left + that.position.left;
- that.offset.top = that.parentData.top + that.position.top;
+ isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
+ isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
- woset = Math.abs( ( that._helper ? that.offset.left - cop.left : ( that.offset.left - co.left ) ) + that.sizeDiff.width );
- hoset = Math.abs( ( that._helper ? that.offset.top - cop.top : ( that.offset.top - co.top ) ) + that.sizeDiff.height );
+ if ( isParent && isOffsetRelative ) {
+ that.offset.left = that.parentData.left + that.position.left;
+ that.offset.top = that.parentData.top + that.position.top;
+ } else {
+ that.offset.left = that.element.offset().left;
+ that.offset.top = that.element.offset().top;
+ }
+
+ woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - co.left)) + that.sizeDiff.width );
+ hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
if ( woset + that.size.width >= that.parentData.width ) {
that.size.width = that.parentData.width - woset;