Skip to content

Commit 20b44cc

Browse files
kborchersscottgonzalez
authored andcommitted
Resizable: Only resize/reposition if size is greater than specified grid
Fixes #9611 Closes gh-1132 (cherry picked from commit 20c1648)
1 parent b6f8ad6 commit 20b44cc

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

tests/unit/resizable/resizable_options.js

+23
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,29 @@ test("grid (wrapped)", function() {
180180
equal( target.height(), 120, "compare height");
181181
});
182182

183+
test( "grid - Resizable: can be moved when grid option is set (#9611)", function() {
184+
expect( 6 );
185+
186+
var oldPosition,
187+
handle = ".ui-resizable-nw",
188+
target = $( "#resizable1" ).resizable({
189+
handles: "all",
190+
grid: 50
191+
});
192+
193+
TestHelpers.resizable.drag( handle, 50, 50 );
194+
equal( target.width(), 50, "compare width" );
195+
equal( target.height(), 50, "compare height" );
196+
197+
oldPosition = target.position();
198+
199+
TestHelpers.resizable.drag( handle, 50, 50 );
200+
equal( target.width(), 50, "compare width" );
201+
equal( target.height(), 50, "compare height" );
202+
equal( target.position().top, oldPosition.top, "compare top" );
203+
equal( target.position().left, oldPosition.left, "compare left" );
204+
});
205+
183206
test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
184207
expect(4);
185208

ui/jquery.ui.resizable.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -956,10 +956,20 @@ $.ui.plugin.add("resizable", "grid", {
956956
that.size.height = newHeight;
957957
that.position.left = op.left - ox;
958958
} else {
959-
that.size.width = newWidth;
960-
that.size.height = newHeight;
961-
that.position.top = op.top - oy;
962-
that.position.left = op.left - ox;
959+
if ( newHeight - gridY > 0 ) {
960+
that.size.height = newHeight;
961+
that.position.top = op.top - oy;
962+
} else {
963+
that.size.height = gridY;
964+
that.position.top = op.top + os.height - gridY;
965+
}
966+
if ( newWidth - gridX > 0 ) {
967+
that.size.width = newWidth;
968+
that.position.left = op.left - ox;
969+
} else {
970+
that.size.width = gridX;
971+
that.position.left = op.left + os.width - gridX;
972+
}
963973
}
964974
}
965975

0 commit comments

Comments
 (0)