Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizable: Fixed sign error on offset calculation. Fixes #9307 Resizable... #989

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions tests/unit/resizable/resizable_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,54 @@ test("stop", function() {
});

})(jQuery);


test( "resize (containment) works with parent with negative offset", function() {

expect( 1 );

var count = 0,
handle = ".ui-resizable-e",
target = $("#resizable1"),
absoluteContainer = target.wrap("<div />").parent(),
fixedContainer = absoluteContainer.wrap("<div />").parent(),
widthBefore,
widthAfter,
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" );

});
2 changes: 1 addition & 1 deletion ui/jquery.ui.resizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ $.ui.plugin.add("resizable", "containment", {
isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));

if(isParent && isOffsetRelative) {
woset -= that.parentData.left;
woset -= Math.abs(that.parentData.left);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notice the spacing Math.abs( that.parentData.left );

}

if (woset + that.size.width >= that.parentData.width) {
Expand Down