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

Make bounds and resizeMode of gif network images respond to styles #353

Closed
wants to merge 4 commits into from
Closed

Make bounds and resizeMode of gif network images respond to styles #353

wants to merge 4 commits into from

Conversation

brentvatne
Copy link
Collaborator

@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.

@vjeux
Copy link
Contributor

vjeux commented Mar 27, 2015

@a2

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is unnecessary.

Copy link
Collaborator Author

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();
Copy link
Contributor

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.

Copy link
Collaborator Author

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

@brentvatne
Copy link
Collaborator Author

@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();
Copy link
Contributor

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.

Copy link
Collaborator Author

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

@a2
Copy link
Contributor

a2 commented Mar 27, 2015

👍

@brentvatne brentvatne changed the title Make bounds and scale of gif network images respond to device and styles Make bounds and resizeMode of gif network images respond to styles Mar 27, 2015
@sahrens
Copy link
Contributor

sahrens commented Apr 1, 2015

Merged internally and synced.

@sahrens sahrens closed this Apr 1, 2015
vjeux pushed a commit to vjeux/react-native that referenced this pull request Apr 13, 2015
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 pushed a commit to vjeux/react-native that referenced this pull request Apr 14, 2015
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 pushed a commit to vjeux/react-native that referenced this pull request Apr 15, 2015
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.
jfrolich pushed a commit to jfrolich/react-native that referenced this pull request Apr 22, 2020
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

Successfully merging this pull request may close these issues.

4 participants