Repository navigation
Keep rotated crop area inside the image - #442
Merged
Merged
Conversation
The boundary clamp ignored rotation, so with a rotated image the crop could show empty corners. Clamp the bounding box of the rotated crop rect instead, and center it when it cannot fit.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
react-avatar-editor | 4e2dbfe | Commit Preview URL Branch Preview URL |
Sep 30 2026, 05:06 PM |
Owner
Author
|
@copilot resolve the merge conflicts in this pull request |
…ndary # Conflicts: # CHANGELOG.md Co-authored-by: mosch <224866+mosch@users.noreply.github.com>
Resolved the changelog conflict and merged |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #377
When the image was rotated, the drag boundary still assumed an unrotated crop. You could drag it until empty corners showed, and the exported image had them too. With the default
disableCanvasRotation, what you see is the crop rect turned around its center.getCroppingRectnow keeps that turned rect's bounding box inside the image, which is exact because the image is axis-aligned in its own coordinates. If the turned rect can't fit at the current zoom, the crop is centered on that axis.disableBoundaryChecks, or when the crop is larger than the image.disableCanvasRotation={false}, the canvas turns along with the image, so the extra 90° is subtracted. Clamping at 90°/270° behaves as before.getCroppingRect, so both are covered.Tests: 8 new core tests. They check that the rotated crop's corners stay inside the image across angles (15, 45, -30, 90, 100, 200°) and drag positions, and cover the "can't fit → center" case and the canvas-rotation mode. 7 of them fail without the fix. The Playwright visual tests (rotation 90/120/180) pass unchanged.