Skip to content

Commit

Permalink
Resizable: Fix aspectRatio cannot be changed after initialization.
Browse files Browse the repository at this point in the history
Fixes #4186
Closes gh-1750
  • Loading branch information
sergeir82 authored and scottgonzalez committed Sep 28, 2016
1 parent c218bee commit c481400
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/resizable/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,28 @@ QUnit.test( "aspectRatio: Resizing can move objects", function( assert ) {
assert.equal( target.position().top, 0, "compare top - no movement" );
} );

QUnit.test( "aspectRatio: aspectRatio can be changed after initialization", function( assert ) {
assert.expect( 4 );

var target = $( "#resizable1" )
.resizable( { aspectRatio: 1 } )
.resizable( "option", "aspectRatio", false );

var handle = ".ui-resizable-e";

testHelper.drag( handle, 80 );

assert.equal( target.width(), 180, "compare width - size change" );
assert.equal( target.height(), 100, "compare height - no size change" );

target.resizable( "option", "aspectRatio", 2 );

testHelper.drag( handle, -40 );

assert.equal( target.width(), 140, "compare width - size change" );
assert.equal( target.height(), 70, "compare height - size change in proper relation" );
} );

QUnit.test( "containment", function( assert ) {
assert.expect( 4 );

Expand Down
3 changes: 3 additions & 0 deletions ui/widgets/resizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ $.widget( "ui.resizable", $.ui.mouse, {
this._removeHandles();
this._setupHandles();
break;
case "aspectRatio":
this._aspectRatio = !!value;
break;
default:
break;
}
Expand Down

0 comments on commit c481400

Please sign in to comment.