Repository navigation
Support percentage width and height - #444
Merged
Merged
Conversation
width and height accept a percentage of the parent element, measured with a ResizeObserver. Size changes now resize the loaded image in place instead of reloading it, the core config updates during render so the canvas size is never a render behind, and the image is loaded once on mount instead of twice.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
react-avatar-editor | 4d01e07 | Commit Preview URL Branch Preview URL |
Sep 30 2026, 01:05 PM |
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.
Closes #399
widthandheightaccept a percentage of the parent element as well as pixels:borderon each side. The parent's content box is measured with aResizeObserver, and the editor follows it when it resizes.display: block. An inline canvas leaves a gap below it, which would make the parent grow on every measurement. Numeric sizes behave exactly as before.%is supported, not other CSS units. The canvas needs a pixel size, and a percentage is the case people actually need.Needed for this to feel right:
width/heightchange reloaded it, which flashed the loading state and reset position and zoom. Now the loaded image is resized in place.onLoadStart/onLoadSuccessfired twice. The new test caught this.Tests:
60vw × 300pxwrapper: the canvas was 600×300 and stayed stable (no feedback growth), and shrank to 420px after narrowing the viewport, with the image still drawn.