Skip to content

Commit 20c1648

Browse files
kborchersscottgonzalez
authored andcommitted
Resizable: Only resize/reposition if size is greater than specified grid
Fixes #9611 Closes gh-1132
1 parent 7741c9f commit 20c1648

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
@@ -224,6 +224,29 @@ test("grid (wrapped)", function() {
224224
equal( target.height(), 120, "compare height");
225225
});
226226

227+
test( "grid - Resizable: can be moved when grid option is set (#9611)", function() {
228+
expect( 6 );
229+
230+
var oldPosition,
231+
handle = ".ui-resizable-nw",
232+
target = $( "#resizable1" ).resizable({
233+
handles: "all",
234+
grid: 50
235+
});
236+
237+
TestHelpers.resizable.drag( handle, 50, 50 );
238+
equal( target.width(), 50, "compare width" );
239+
equal( target.height(), 50, "compare height" );
240+
241+
oldPosition = target.position();
242+
243+
TestHelpers.resizable.drag( handle, 50, 50 );
244+
equal( target.width(), 50, "compare width" );
245+
equal( target.height(), 50, "compare height" );
246+
equal( target.position().top, oldPosition.top, "compare top" );
247+
equal( target.position().left, oldPosition.left, "compare left" );
248+
});
249+
227250
test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
228251
expect(4);
229252

ui/jquery.ui.resizable.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,20 @@ $.ui.plugin.add("resizable", "grid", {
10021002
that.size.height = newHeight;
10031003
that.position.left = op.left - ox;
10041004
} else {
1005-
that.size.width = newWidth;
1006-
that.size.height = newHeight;
1007-
that.position.top = op.top - oy;
1008-
that.position.left = op.left - ox;
1005+
if ( newHeight - gridY > 0 ) {
1006+
that.size.height = newHeight;
1007+
that.position.top = op.top - oy;
1008+
} else {
1009+
that.size.height = gridY;
1010+
that.position.top = op.top + os.height - gridY;
1011+
}
1012+
if ( newWidth - gridX > 0 ) {
1013+
that.size.width = newWidth;
1014+
that.position.left = op.left - ox;
1015+
} else {
1016+
that.size.width = gridX;
1017+
that.position.left = op.left + os.width - gridX;
1018+
}
10091019
}
10101020
}
10111021

0 commit comments

Comments
 (0)