Skip to content
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

Cropper component cannot move to the edges of an image when used inside a modal. #428

Closed
Dinishka opened this issue Dec 6, 2022 · 3 comments

Comments

@Dinishka
Copy link

Dinishka commented Dec 6, 2022

Describe the bug
I am using react-easy-crop with mantine components. Currently I am loading the cropper component inside a mantine modal. The issue is when the cropper is loaded inside a modal, I can't move it to the edges of the selected image (it's like padded). One thing I noticed is that when I open the modal and then open the console from the same window (from right, left or bottom), the above mentioned issue goes away.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/fervent-pine-xiucoj
  2. Click on 'Open cropping dialog'
  3. Select an image from the file system
  4. Try to move the cropper to edges of the image

Expected behavior
Should be able to move the cropper anywhere inside the selected image, so we can crop any part form that image.

@ValentinH
Copy link
Owner

This is due to the opening animation of the modal conflicting with the internal logic of the cropper to compute its size.
When you resize the window, it makes the cropper recomputes its size so that's why it fixes the issue.

You can fix this by changing the animation to fade to avoid the cropper size to change while the modal is opening. See this sandbox: https://codesandbox.io/s/gallant-brown-ixjdd3

If you really don't want to change the animation, you need to wait until the animation is complete to actually render the cropper.

@Dinishka
Copy link
Author

Dinishka commented Dec 6, 2022

Thank you so much. Closing this issue because it has resolved with the given solution.

@ljrahn
Copy link

ljrahn commented Sep 15, 2023

oh my thank you. i could have spent hours on this, but luckily i only spent an hour xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants