Skip to content

Commit

Permalink
Make bounds and scale of gif network images respond to device and styles
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Brent Vatne committed Mar 27, 2015
1 parent fe73897 commit df8dd63
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions Libraries/Image/RCTNetworkImageView.m
Expand Up @@ -62,10 +62,7 @@ - (void)setImageURL:(NSURL *)imageURL resetToDefaultImageWhileLoading:(BOOL)rese
_downloadToken = [_imageDownloader downloadDataForURL:imageURL block:^(NSData *data, NSError *error) {
if (data) {
CAKeyframeAnimation *animation = RCTGIFImageWithData(data);
CGImageRef firstFrame = (__bridge CGImageRef)animation.values.firstObject;
self.layer.bounds = CGRectMake(0, 0, CGImageGetWidth(firstFrame), CGImageGetHeight(firstFrame));
self.layer.contentsScale = 1.0;
self.layer.contentsGravity = kCAGravityResizeAspect;
self.layer.minificationFilter = kCAFilterLinear;
self.layer.magnificationFilter = kCAFilterLinear;
[self.layer addAnimation:animation forKey:@"contents"];
Expand Down

0 comments on commit df8dd63

Please sign in to comment.