-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Resizable: Fix aspectRatio cannot be changed after initialization #1750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for your pull request. It looks like this may be your first contribution to a jQuery Foundation project, if so we need you to sign our Contributor License Agreement (CLA). 📝 Please visit http://contribute.jquery.org/CLA/ to sign. After you signed, the PR is checked again automatically after a minute. If there's still an issue, please reply here to let us know. If you've already signed our CLA, it's possible your git author information doesn't match your CLA signature (both your name and email have to match), for more information, check the status of your CLA check. |
<div id="resizable1">I'm a resizable.</div> | ||
<div id="resizer1" class="ui-resizable-handle ui-resizable-s"></div> | ||
</div> | ||
<div id="container"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put the indentation back to how it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit 2edcbe3
@@ -226,6 +226,9 @@ $.widget( "ui.resizable", $.ui.mouse, { | |||
this._removeHandles(); | |||
this._setupHandles(); | |||
break; | |||
case "aspectRatio": | |||
this._aspectRatio = !!value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot cast to a boolean here, numbers are used to define the ratio.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have two properties this.aspectRatio
and this._aspectRatio
.
In aspectRatio we have numbers are used to define the ratio. It is set in _mouseStart
method https://github.com/jquery/jquery-ui/blob/1.12.1/ui/widgets/resizable.js#L397.
We have numeric aspectRatio
even in cases when we do not set aspectRatio in options, because we must know it when resize with shiftKey
pressed.
We use _aspectRatio
to know save aspect ratio without pressed shiftKey
(anytime) or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests for setting aspectRatio
numeric value. Commit 02796d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for pointing that out. Looking at just the diff, I forgot about the two.
|
||
testHelper.drag( handle, 80 ); | ||
|
||
assert.equal( target.width(), 180, "compare width - size change" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous space after dash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit ffeb5ab
Put the indentation back to how it was. Fixes #4186
Remove extraneous space after dash. Fixes #4186
Add tests for setting aspectRatio numeric value. Fixes #4186
Fixes #4186