From 89fce9aead21404bffdbcb20d87ddaad1254b8c6 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Fri, 27 Mar 2015 12:06:46 -0700 Subject: [PATCH] Make bounds and scale of gif network images respond to device and styles 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 https://github.com/facebook/react-native/pull/353 Github Author: Brent Vatne Test Plan: Imported from GitHub, without a `Test Plan:` line. --- Libraries/Image/RCTNetworkImageView.m | 3 --- 1 file changed, 3 deletions(-) diff --git a/Libraries/Image/RCTNetworkImageView.m b/Libraries/Image/RCTNetworkImageView.m index c97b97cfde..b4a6cea002 100644 --- a/Libraries/Image/RCTNetworkImageView.m +++ b/Libraries/Image/RCTNetworkImageView.m @@ -62,10 +62,7 @@ _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"];