mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
Resizable: Fix containment calculation with relative parent
Remove an incorrect fix introduced in47cd5b6f
that causes width calculations to be incorrect once the correct fix was introduced inc03cb807
Fixes #10140
This commit is contained in:
parent
5ddc7cd4d3
commit
2779212a0e
@ -155,7 +155,8 @@ test( "aspectRatio: Resizing can move objects", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test( "containment", function() {
|
test( "containment", function() {
|
||||||
expect( 6 );
|
expect( 8 );
|
||||||
|
|
||||||
var element = $( "#resizable1" ).resizable({
|
var element = $( "#resizable1" ).resizable({
|
||||||
containment: "#container"
|
containment: "#container"
|
||||||
});
|
});
|
||||||
@ -180,6 +181,19 @@ test( "containment", function() {
|
|||||||
|
|
||||||
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 300 );
|
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 300 );
|
||||||
equal( element.height(), 400, "element able to resize itself to max allowable height within container" );
|
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() {
|
test("grid", function() {
|
||||||
|
@ -774,7 +774,7 @@ $.ui.plugin.add( "resizable", "containment", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
resize: function( event ) {
|
resize: function( event ) {
|
||||||
var woset, hoset, isParent, isOffsetRelative,
|
var woset, hoset,
|
||||||
that = $( this ).resizable( "instance" ),
|
that = $( this ).resizable( "instance" ),
|
||||||
o = that.options,
|
o = that.options,
|
||||||
co = that.containerOffset,
|
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 );
|
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 );
|
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 ) {
|
if ( woset + that.size.width >= that.parentData.width ) {
|
||||||
that.size.width = that.parentData.width - woset;
|
that.size.width = that.parentData.width - woset;
|
||||||
if ( pRatio ) {
|
if ( pRatio ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user