Cancel contents animation before setting new contents in RCTNetworkImageView
Summary: This is a fix for #322 When setting a new image via the imageURL property, the new image doesn't always replace the previous one when it is finished downloading because the image view has a previously instated layer animation on its contents. This cancels any animation prior to setting the new contents to fix the issue. Closes https://github.com/facebook/react-native/pull/337 Github Author: Julius Parishy <julius> Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
parent
35589d6f09
commit
7bcb467526
|
@ -75,6 +75,7 @@
|
||||||
} else {
|
} else {
|
||||||
_downloadToken = [_imageDownloader downloadImageForURL:imageURL size:self.bounds.size scale:RCTScreenScale() block:^(UIImage *image, NSError *error) {
|
_downloadToken = [_imageDownloader downloadImageForURL:imageURL size:self.bounds.size scale:RCTScreenScale() block:^(UIImage *image, NSError *error) {
|
||||||
if (image) {
|
if (image) {
|
||||||
|
[self.layer removeAnimationForKey:@"contents"];
|
||||||
self.layer.contentsScale = image.scale;
|
self.layer.contentsScale = image.scale;
|
||||||
self.layer.contents = (__bridge id)image.CGImage;
|
self.layer.contents = (__bridge id)image.CGImage;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue