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

cropSize in percentage #555

Open
Rastraponovich opened this issue Aug 14, 2024 · 4 comments
Open

cropSize in percentage #555

Rastraponovich opened this issue Aug 14, 2024 · 4 comments

Comments

@Rastraponovich
Copy link

Hello, Is it possible to specify the CropSize as a percentage rather than in pixels? There is a need to set the size in % due to different screen sizes. if you specify a clear value, the Crop may go beyond the screen, as a result of which the final result will differ from the expected one.

Ideally, I would like to be able to set not only the height and width, but also control the position of the Crop inside the container as a percentage.

Currently, the size calculation occurs before mounting the component into the DOM through hooks and requests to the Window object

@ValentinH
Copy link
Owner

You most probably should use the aspect property. This is the ratio between width and height.

@Rastraponovich
Copy link
Author

But if I don't set the CropSize then the Crop will not have the required dimensions. Example. In my case, I need the x axis to be 100% and the y axis according to aspectRatio. Now the Crop width without the CropSize parameter is not 100%. maybe I didn't complete something according to the instructions

@ValentinH
Copy link
Owner

The objectFit prop might be what you are looking for.
In general, I don't think that the cropSize should be used as it's not responsive. The important thing when cropping is the aspect of the Cropper + the position and the zoom. From these, every possible crop can be represented.

Once the user has selected the cropped area, then you can convert the percentage selection to a specific pixel size with simple maths.

@Rastraponovich
Copy link
Author

Thanks

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

2 participants