Skip to content

Commit ae91762

Browse files
committed
Resizable: Fix aspectRatio cannot be changed after initialization.
Fixes #4186
1 parent c571d2f commit ae91762

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

tests/unit/resizable/options.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,21 @@ 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( 2 );
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+
158173
QUnit.test( "containment", function( assert ) {
159174
assert.expect( 4 );
160175

tests/unit/resizable/resizable.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444
<div id="qunit"></div>
4545
<div id="qunit-fixture">
4646

47-
<div id="container">
48-
<div id="resizable1">I'm a resizable.</div>
49-
<div id="resizer1" class="ui-resizable-handle ui-resizable-s"></div>
50-
</div>
47+
<div id="container">
48+
<div id="resizable1">I'm a resizable.</div>
49+
<div id="resizer1" class="ui-resizable-handle ui-resizable-s"></div>
50+
</div>
5151

52-
<div id="container2">
53-
<div id="parent">
54-
<div id="child">I'm a resizable.</div>
52+
<div id="container2">
53+
<div id="parent">
54+
<div id="child">I'm a resizable.</div>
55+
</div>
5556
</div>
56-
</div>
57-
<img src="images/test.jpg" id="resizable2" alt="solid gray">
57+
<img src="images/test.jpg" id="resizable2" alt="solid gray">
5858

5959
</div>
6060
</body>

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)