Resizable: Fix containment calculation with relative parent

Remove an incorrect fix introduced in 47cd5b6f that causes
width calculations to be incorrect once the correct fix
was introduced in c03cb807

Fixes #10140
This commit is contained in:
Mike Sherov 2014-08-04 08:18:35 -04:00
parent 5ddc7cd4d3
commit 2779212a0e
2 changed files with 16 additions and 9 deletions

View File

@ -155,7 +155,8 @@ test( "aspectRatio: Resizing can move objects", function() {
});
test( "containment", function() {
expect( 6 );
expect( 8 );
var element = $( "#resizable1" ).resizable({
containment: "#container"
});
@ -180,6 +181,19 @@ test( "containment", function() {
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 300 );
equal( element.height(), 400, "element able to resize itself to max allowable height within container" );
// http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong
// when containment element is "position: relative"
element = $( "#child" ).resizable({
containment: "parent",
handles: "all"
});
TestHelpers.resizable.drag( ".ui-resizable-e", 300, 0 );
equal( element.width(), 300, "element able to resize itself to max allowable width within container" );
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 300 );
equal( element.height(), 300, "element able to resize itself to max allowable height within container" );
});
test("grid", function() {

View File

@ -774,7 +774,7 @@ $.ui.plugin.add( "resizable", "containment", {
},
resize: function( event ) {
var woset, hoset, isParent, isOffsetRelative,
var woset, hoset,
that = $( this ).resizable( "instance" ),
o = that.options,
co = that.containerOffset,
@ -815,13 +815,6 @@ $.ui.plugin.add( "resizable", "containment", {
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 );
isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
if ( isParent && isOffsetRelative ) {
woset -= Math.abs( that.parentData.left );
}
if ( woset + that.size.width >= that.parentData.width ) {
that.size.width = that.parentData.width - woset;
if ( pRatio ) {