-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Make bounds and resizeMode of gif network images respond to styles #353
Conversation
CGImageRef firstFrame = (__bridge CGImageRef)animation.values.firstObject; | ||
self.layer.bounds = CGRectMake(0, 0, CGImageGetWidth(firstFrame), CGImageGetHeight(firstFrame)); | ||
self.layer.contentsScale = 1.0; | ||
self.layer.bounds = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); |
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 line is unnecessary.
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.
Good point, removed
self.layer.bounds = CGRectMake(0, 0, CGImageGetWidth(firstFrame), CGImageGetHeight(firstFrame)); | ||
self.layer.contentsScale = 1.0; | ||
self.layer.bounds = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); | ||
self.layer.contentsScale = RCTScreenScale(); |
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.
I think this line is unnecessary but I may be wrong.
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.
If I remove it then the image does not show up at all, so it seems necessary
@a2 - thanks for the feedback, let me know if there's anything else you'd like me to do here! |
self.layer.bounds = CGRectMake(0, 0, CGImageGetWidth(firstFrame), CGImageGetHeight(firstFrame)); | ||
self.layer.contentsScale = 1.0; | ||
self.layer.contentsGravity = kCAGravityResizeAspect; | ||
self.layer.contentsScale = RCTScreenScale(); |
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.
Basically we don't currently support @2x
or @3x
GIFs so maybe change the contentsScale
to 1.0
? Or, if you want to keep RCTScreenScale()
, we need to add that support, maybe by checking the filename suffix before the extension.
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.
@a2 - good point, let's just make this 1.0 and we can open a separate issue for @2x
+ support if you like
👍 |
Merged internally and synced. |
Summary: @vjeux and I were discussing this in irc an discovered that network gif images did not respond how they should to width, height or flex properties. Along the way I also noticed that the scale was not changing depending on the device. This PR fixes that, so now you can do `flex: 1` on a gif image to have it stretch to the whole screen. [Minimum reproducible example here](https://gist.github.com/brentvatne/f745377b0789162a28df) - try this without and then with the changes of this PR to see. Closes facebook#353 Github Author: Brent Vatne <brent.vatne@madriska.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
Summary: @vjeux and I were discussing this in irc an discovered that network gif images did not respond how they should to width, height or flex properties. Along the way I also noticed that the scale was not changing depending on the device. This PR fixes that, so now you can do `flex: 1` on a gif image to have it stretch to the whole screen. [Minimum reproducible example here](https://gist.github.com/brentvatne/f745377b0789162a28df) - try this without and then with the changes of this PR to see. Closes facebook#353 Github Author: Brent Vatne <brent.vatne@madriska.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
Summary: @vjeux and I were discussing this in irc an discovered that network gif images did not respond how they should to width, height or flex properties. Along the way I also noticed that the scale was not changing depending on the device. This PR fixes that, so now you can do `flex: 1` on a gif image to have it stretch to the whole screen. [Minimum reproducible example here](https://gist.github.com/brentvatne/f745377b0789162a28df) - try this without and then with the changes of this PR to see. Closes facebook#353 Github Author: Brent Vatne <brent.vatne@madriska.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
@vjeux and I were discussing this in irc an discovered that network gif images did not respond how they should to width, height or flex properties. This PR fixes that, so now you can do
flex: 1
on a gif image to have it stretch to the whole screen. Minimum reproducible example here - try this without and then with the changes of this PR to see.