Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

sergeir82
Copy link
Contributor

Fixes #4186

@jquerybot
Copy link

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">
Copy link
Member

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.

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Member

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" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous space after dash.

Copy link
Contributor Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants