Skip to content

Commit

Permalink
Resizable: Only resize/reposition if size is greater than specified grid
Browse files Browse the repository at this point in the history
Fixes #9611
Closes gh-1132
  • Loading branch information
kborchers authored and scottgonzalez committed Jan 15, 2014
1 parent 7741c9f commit 20c1648
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
23 changes: 23 additions & 0 deletions tests/unit/resizable/resizable_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,29 @@ test("grid (wrapped)", function() {
equal( target.height(), 120, "compare height");
});

test( "grid - Resizable: can be moved when grid option is set (#9611)", function() {
expect( 6 );

var oldPosition,
handle = ".ui-resizable-nw",
target = $( "#resizable1" ).resizable({
handles: "all",
grid: 50
});

TestHelpers.resizable.drag( handle, 50, 50 );
equal( target.width(), 50, "compare width" );
equal( target.height(), 50, "compare height" );

oldPosition = target.position();

TestHelpers.resizable.drag( handle, 50, 50 );
equal( target.width(), 50, "compare width" );
equal( target.height(), 50, "compare height" );
equal( target.position().top, oldPosition.top, "compare top" );
equal( target.position().left, oldPosition.left, "compare left" );
});

test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
expect(4);

Expand Down
18 changes: 14 additions & 4 deletions ui/jquery.ui.resizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,20 @@ $.ui.plugin.add("resizable", "grid", {
that.size.height = newHeight;
that.position.left = op.left - ox;
} else {
that.size.width = newWidth;
that.size.height = newHeight;
that.position.top = op.top - oy;
that.position.left = op.left - ox;
if ( newHeight - gridY > 0 ) {
that.size.height = newHeight;
that.position.top = op.top - oy;
} else {
that.size.height = gridY;
that.position.top = op.top + os.height - gridY;
}
if ( newWidth - gridX > 0 ) {
that.size.width = newWidth;
that.position.left = op.left - ox;
} else {
that.size.width = gridX;
that.position.left = op.left + os.width - gridX;
}
}
}

Expand Down

0 comments on commit 20c1648

Please sign in to comment.