-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
fix: replace objectFit: 'auto-cover' by 'cover' with adjusted logic #466
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ecc084a:
|
Hi, @ValentinH! Any chance that functionality could be added? |
Thanks for this PR. Before merging, I need to take a bit of time to understand why we need so many options. I'm wondering if this new behavior should not be what auto-cover was supposed to be doing in the first place 😁 |
Thanks for the answer!
I was thinking the same as that's how the default object-fit: cover works 😁 Agree on 'fill', just want to note that 'object-fit: fill' usually stretches the image |
One more note here: It could make sense to mark auto-cover as deprecated and name the new option just 'cover' |
@kruchkou I understand why I said that what you are looking for is what Therefore, I don't think we need a new option. Instead, we need to also take the container aspect into account when picking between If we manage to have this work, I would just name this option |
@ValentinH
I assume that comparing the container aspect and the picture aspect could help to determine the proper image size and alignment. |
The decision should be like this from what I could observe:
Therefore, I would implement the above logic as part of a new |
@kruchkou I managed to find a simple rule to pick between horizontal and vertical cover: mediaAspect < containerAspect ? 'horizontal-cover' : 'vertical-cover' I updated the PR to rename Demo: https://codesandbox.io/s/react-easy-crop-forked-d93p44?file=/src/index.js |
Hello @ValentinH! That is exactly what I was needed, thanks for the changes! |
🚀 PR was released in |
Release notes
the
objectFit
auto-cover
option was removed and replaced bycover
. While doing so, the logic detecting the right value to choose betweenhorizontal
andvertical
was rewritten from scratch. The algorithm is now much better at picking the right choice.