-
Notifications
You must be signed in to change notification settings - Fork 579
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
Is is possible to generate a percentage center point instead of absolute boundary? #81
Comments
I found another workaround, set the width=height=50px (or small), minScale=0,5 (or small). It will generate a square cropped area, use the central point of this area as center point. The result is more making sense. |
just take x/width*100 to get %. |
Here is the full code to convert the crop to css background-position:
Personally I only use
If you only have one img ratio, you do not need to calculate multiple ratios, but this method works pretty well for varying ratios. You might want to use more extreme ratios like 2:1 and 1:2 if you have to cover a wider spectrum. |
Hi, @jwagner
This is an awesome library, thank you for creating it!
I am considering to use the library in production environment, with responsiveness support. However, the absolute cropped boundary numbers are not very friendly to responsiveness. If the calculation result is a center point with percentage, we can use the following CSS styles to stick to that center point, then it will show good in PC view or mobile view.
Now, I am calculating the central point of the crop result as the center point. That is working but not really accurate.
More ideas?
The text was updated successfully, but these errors were encountered: