Resizable: correct aspectRatio handling with min/max dimensions - Fixed #4951 #295
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes an incorrect behavior when trying to maintain the aspect ratio with min/max width/height.
It does so by computing the dimensions of a "virtual box" that abides by the min/max width/height but at the same time follows the aspect ratio constraint.
The virtual boundaries are computed inside the _updateVirtualBoundaries method.
I also fixed two bugs in the _updateRatio method.
Finally, I updated _respectSize to use the "virtual boundaries" rather than the min/max width/height set in the options (in normal cases, the virtual boundaries will correspond to min/max width/height)
The resizable unit tests on FF4.0 / Chrome 11 now pass 128 tests out of 137 (it's not failing any unit test related to preserve aspect anymore). The fix is purely algorithmic so that should work on other browsers as well.
If there is anything wrong in the coding style, please let me know. I'll update