Skip to content

Commit 2779212

Browse files
committed
Resizable: Fix containment calculation with relative parent
Remove an incorrect fix introduced in 47cd5b6 that causes width calculations to be incorrect once the correct fix was introduced in c03cb80 Fixes #10140
1 parent 5ddc7cd commit 2779212

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

tests/unit/resizable/resizable_options.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ test( "aspectRatio: Resizing can move objects", function() {
155155
});
156156

157157
test( "containment", function() {
158-
expect( 6 );
158+
expect( 8 );
159+
159160
var element = $( "#resizable1" ).resizable({
160161
containment: "#container"
161162
});
@@ -180,6 +181,19 @@ test( "containment", function() {
180181

181182
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 300 );
182183
equal( element.height(), 400, "element able to resize itself to max allowable height within container" );
184+
185+
// http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong
186+
// when containment element is "position: relative"
187+
element = $( "#child" ).resizable({
188+
containment: "parent",
189+
handles: "all"
190+
});
191+
192+
TestHelpers.resizable.drag( ".ui-resizable-e", 300, 0 );
193+
equal( element.width(), 300, "element able to resize itself to max allowable width within container" );
194+
195+
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 300 );
196+
equal( element.height(), 300, "element able to resize itself to max allowable height within container" );
183197
});
184198

185199
test("grid", function() {

ui/resizable.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ $.ui.plugin.add( "resizable", "containment", {
774774
},
775775

776776
resize: function( event ) {
777-
var woset, hoset, isParent, isOffsetRelative,
777+
var woset, hoset,
778778
that = $( this ).resizable( "instance" ),
779779
o = that.options,
780780
co = that.containerOffset,
@@ -815,13 +815,6 @@ $.ui.plugin.add( "resizable", "containment", {
815815
woset = Math.abs( ( that._helper ? that.offset.left - cop.left : ( that.offset.left - co.left ) ) + that.sizeDiff.width );
816816
hoset = Math.abs( ( that._helper ? that.offset.top - cop.top : ( that.offset.top - co.top ) ) + that.sizeDiff.height );
817817

818-
isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
819-
isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
820-
821-
if ( isParent && isOffsetRelative ) {
822-
woset -= Math.abs( that.parentData.left );
823-
}
824-
825818
if ( woset + that.size.width >= that.parentData.width ) {
826819
that.size.width = that.parentData.width - woset;
827820
if ( pRatio ) {

0 commit comments

Comments
 (0)