Cannot resize or move after onImageLoaded
See original GitHub issueThis is probably related to #280
Steps to reproduce:
Select image, preferable a portrait or landscape for best effect. Click a handle to resize OR click and drag in the middle to move the crop area.
Expected results Crop area is resized or moved
Actual results Nothing happens on FIRST interaction, but if I try again, I get the expected results.
DEMO
I’ve forked your example from the README here: https://codesandbox.io/s/react-image-crop-demo-3mtjy
What I wish to achieve: I want to have a default square crop area when react-image-crop loads.
I’ve set the initial crop aspect ratio to 1 just so I can reuse the state in onImageLoaded. Then the function looks like this:
onImageLoaded = image => {
const { width, height } = image;
let crop;
if (width > height) {
crop = {
...this.state.crop,
width: height,
height,
x: width / 2 - height / 2,
y: 0
};
} else {
crop = {
...this.state.crop,
width,
height: width,
x: 0,
y: height / 2 - width / 2
};
}
this.setState({ crop });
return false;
};
I seem to need to provide both width and height for this to work.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Can't resize with Move Tool - Adobe Support Community
Hi. To resize the entire Image, use the Image menu > Image size; To resize a layer ot selection, use Edit > Free...
Read more >Windows 11:Can't move or resize windows/applications
I updated windows not too long ago and now my application windows don't want to move or resize. It's pretty annoying.
Read more >react-image-crop - npm
A callback which happens when a user starts dragging or resizing. It is convenient to manipulate elements outside this component. onDragEnd?: (e ...
Read more >Can't resize an ImageView from a dynamic declaration
But this is not : if I declare my imageView without using XML, it just won't resize, and also it won't move when...
Read more >Image Resizing Problems in Microsoft Publisher - Sign In
Issue/Question. I have inserted an image into Publisher, but when I try to move or resize the image it displays strange graphical glitches ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi there! That certainly isn’t the worst work-around I’ve seen! 😄 My issue is resolved.
You can workaround the issue by adding
unit: 'px'
to your crop in onImageLoaded, though it should have defaulted to this (bug)