mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Resizable: Fixed sign error on offset calculation. Fixes #9307 - Resizable: Erratic behavior of contained elements within scrollable grandparents
(cherry picked from commit 6df5c1a4ae
)
This commit is contained in:
parent
e4a194ce42
commit
1660c761e7
@ -170,4 +170,51 @@ test("stop", function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "resize (containment) works with parent with negative offset", function() {
|
||||||
|
|
||||||
|
expect( 1 );
|
||||||
|
|
||||||
|
var widthBefore, widthAfter,
|
||||||
|
handle = ".ui-resizable-e",
|
||||||
|
target = $( "#resizable1" ),
|
||||||
|
absoluteContainer = target.wrap( "<div />" ).parent(),
|
||||||
|
fixedContainer = absoluteContainer.wrap( "<div />" ).parent(),
|
||||||
|
increaseWidthBy = 50;
|
||||||
|
|
||||||
|
// position fixed container in window top left
|
||||||
|
fixedContainer.css({
|
||||||
|
width: 400,
|
||||||
|
height: 100,
|
||||||
|
position: "fixed",
|
||||||
|
top: 0,
|
||||||
|
left: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
// position absolute container within fixed on slightly outside window
|
||||||
|
absoluteContainer.css({
|
||||||
|
width: 400,
|
||||||
|
height: 100,
|
||||||
|
position: "absolute",
|
||||||
|
top: 0,
|
||||||
|
left: -50
|
||||||
|
});
|
||||||
|
|
||||||
|
// set up resizable to be contained within absolute container
|
||||||
|
target.resizable({
|
||||||
|
handles: "all",
|
||||||
|
containment: "parent"
|
||||||
|
}).css({
|
||||||
|
width: 300
|
||||||
|
});
|
||||||
|
|
||||||
|
widthBefore = target.width();
|
||||||
|
|
||||||
|
TestHelpers.resizable.drag( handle, increaseWidthBy, 0 );
|
||||||
|
|
||||||
|
widthAfter = target.width();
|
||||||
|
|
||||||
|
equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" );
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
4
ui/jquery.ui.resizable.js
vendored
4
ui/jquery.ui.resizable.js
vendored
@ -774,8 +774,8 @@ $.ui.plugin.add("resizable", "containment", {
|
|||||||
isParent = that.containerElement.get(0) === that.element.parent().get(0);
|
isParent = that.containerElement.get(0) === that.element.parent().get(0);
|
||||||
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
|
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
|
||||||
|
|
||||||
if(isParent && isOffsetRelative) {
|
if ( isParent && isOffsetRelative ) {
|
||||||
woset -= that.parentData.left;
|
woset -= Math.abs( that.parentData.left );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (woset + that.size.width >= that.parentData.width) {
|
if (woset + that.size.width >= that.parentData.width) {
|
||||||
|
Loading…
Reference in New Issue
Block a user