Skip to content

Commit c481400

Browse files
sergeir82scottgonzalez
authored andcommitted
Resizable: Fix aspectRatio cannot be changed after initialization.
Fixes #4186 Closes gh-1750
1 parent c218bee commit c481400

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/unit/resizable/options.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,28 @@ QUnit.test( "aspectRatio: Resizing can move objects", function( assert ) {
155155
assert.equal( target.position().top, 0, "compare top - no movement" );
156156
} );
157157

158+
QUnit.test( "aspectRatio: aspectRatio can be changed after initialization", function( assert ) {
159+
assert.expect( 4 );
160+
161+
var target = $( "#resizable1" )
162+
.resizable( { aspectRatio: 1 } )
163+
.resizable( "option", "aspectRatio", false );
164+
165+
var handle = ".ui-resizable-e";
166+
167+
testHelper.drag( handle, 80 );
168+
169+
assert.equal( target.width(), 180, "compare width - size change" );
170+
assert.equal( target.height(), 100, "compare height - no size change" );
171+
172+
target.resizable( "option", "aspectRatio", 2 );
173+
174+
testHelper.drag( handle, -40 );
175+
176+
assert.equal( target.width(), 140, "compare width - size change" );
177+
assert.equal( target.height(), 70, "compare height - size change in proper relation" );
178+
} );
179+
158180
QUnit.test( "containment", function( assert ) {
159181
assert.expect( 4 );
160182

ui/widgets/resizable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ $.widget( "ui.resizable", $.ui.mouse, {
226226
this._removeHandles();
227227
this._setupHandles();
228228
break;
229+
case "aspectRatio":
230+
this._aspectRatio = !!value;
231+
break;
229232
default:
230233
break;
231234
}

0 commit comments

Comments
 (0)