-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Add Image resizeMode center to iOS #8792
Conversation
By analyzing the blame information on this pull request, we identified @JoelMarcey and @nicklockwood to be potential reviewers. |
|
||
// Make sure the image is not clipped by the target. | ||
if (sourceSize.height > destSize.height) { | ||
sourceSize.width = destSize.width = destSize.width; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This expression seems incorrect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javache
Are you talking about destSize.width = destSize.width
(which is used elsewhere so I just copied it)?
Or do you mean I should be using the aspect ratios instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a bug in the other code then too. Could you clean up all of them up? It probably should just be sourceSize.width = destSize.width
039b293
to
7b591f4
Compare
@javache Added another commit that removes the extra assignments. 👍 |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review internal test results. |
bee1180
Summary: Addresses this comment: facebook#2296 (comment) This pull request adds the `center` value to `ImageResizeMode`. When set, it will center the image within its frame. If the image is larger than its frame, the image is downscaled while maintaining its aspect ratio. That is how the Android implementation works, too. Sorry, don't have time to write tests. 😢 Any reviewers should make sure `RCTTargetRect` returns the correct value when: - the image is smaller than its frame (ie: no downscaling needed) - the image is larger than its frame (should be downscaled to avoid clipping) Closes facebook#8792 Differential Revision: D3586134 Pulled By: javache fbshipit-source-id: 78fb8e5928284003437dac2c9ad264fa584f73ec
Summary: Addresses this comment: facebook#2296 (comment) This pull request adds the `center` value to `ImageResizeMode`. When set, it will center the image within its frame. If the image is larger than its frame, the image is downscaled while maintaining its aspect ratio. That is how the Android implementation works, too. Sorry, don't have time to write tests. 😢 Any reviewers should make sure `RCTTargetRect` returns the correct value when: - the image is smaller than its frame (ie: no downscaling needed) - the image is larger than its frame (should be downscaled to avoid clipping) Closes facebook#8792 Differential Revision: D3586134 Pulled By: javache fbshipit-source-id: 78fb8e5928284003437dac2c9ad264fa584f73ec
Summary: Addresses this comment: facebook#2296 (comment) This pull request adds the `center` value to `ImageResizeMode`. When set, it will center the image within its frame. If the image is larger than its frame, the image is downscaled while maintaining its aspect ratio. That is how the Android implementation works, too. Sorry, don't have time to write tests. 😢 Any reviewers should make sure `RCTTargetRect` returns the correct value when: - the image is smaller than its frame (ie: no downscaling needed) - the image is larger than its frame (should be downscaled to avoid clipping) Closes facebook#8792 Differential Revision: D3586134 Pulled By: javache fbshipit-source-id: 78fb8e5928284003437dac2c9ad264fa584f73ec
Summary: `<Image resizeMode="center">` already works on iOS (implemented in #8792), but is neither tested nor documented the way the other `resizeMode` values are. This PR primarily enables the relevant RNTester case on iOS, and secondarily copies over the doc comment from `Image.android.js` to `Image.ios.js`. A PR to `react-native-website` will follow shortly and it is there I will try and revise the wording a bit. Updated RNTester screenshot (iOS): <img src=https://user-images.githubusercontent.com/2246565/35470720-44b38282-0357-11e8-941c-1b3c5a1b2f3b.png width=300> react-native-website PR coming soon. [IOS] [MINOR] [Image] - Include resizeMode=center in RNTester Closes #17759 Differential Revision: D6829051 Pulled By: hramos fbshipit-source-id: c6e0000a75765e8bf3a1d0306aaafad002b14a58
Summary: Addresses this comment: facebook/react-native#2296 (comment) This pull request adds the `center` value to `ImageResizeMode`. When set, it will center the image within its frame. If the image is larger than its frame, the image is downscaled while maintaining its aspect ratio. That is how the Android implementation works, too. Sorry, don't have time to write tests. 😢 Any reviewers should make sure `RCTTargetRect` returns the correct value when: - the image is smaller than its frame (ie: no downscaling needed) - the image is larger than its frame (should be downscaled to avoid clipping) Closes facebook/react-native#8792 Differential Revision: D3586134 Pulled By: javache fbshipit-source-id: 78fb8e5928284003437dac2c9ad264fa584f73ec
Addresses this comment: #2296 (comment)
This pull request adds the
center
value toImageResizeMode
.When set, it will center the image within its frame.
If the image is larger than its frame, the image is downscaled while maintaining its aspect ratio.
That is how the Android implementation works, too.
Sorry, don't have time to write tests. 😢
Any reviewers should make sure
RCTTargetRect
returns the correct value when: