react-native-fast-image 8.6.42 → 8.6.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,10 +50,34 @@ static CFTimeInterval FFFEnteredBackgroundAt = 0;
50
50
  - (void) setResizeMode: (RCTResizeMode)resizeMode {
51
51
  if (_resizeMode != resizeMode) {
52
52
  _resizeMode = resizeMode;
53
- self.contentMode = (UIViewContentMode) resizeMode;
53
+ [self updateContentMode];
54
54
  }
55
55
  }
56
56
 
57
+ // The content mode for resizeMode. `center` scales an image larger than the
58
+ // view down to fit, as React Native's Image and Android do (#866); only a
59
+ // smaller one is shown at its own size. UIViewContentModeCenter alone showed
60
+ // large images at full size, cropped. So it depends on the image and the
61
+ // view's size.
62
+ - (void) updateContentMode {
63
+ UIViewContentMode contentMode = (UIViewContentMode) _resizeMode;
64
+ if (_resizeMode == RCTResizeModeCenter) {
65
+ CGSize imageSize = super.image.size;
66
+ CGSize viewSize = self.bounds.size;
67
+ if (imageSize.width > viewSize.width || imageSize.height > viewSize.height) {
68
+ contentMode = UIViewContentModeScaleAspectFit;
69
+ }
70
+ }
71
+ if (self.contentMode != contentMode) {
72
+ self.contentMode = contentMode;
73
+ }
74
+ }
75
+
76
+ - (void) layoutSubviews {
77
+ [super layoutSubviews];
78
+ [self updateContentMode];
79
+ }
80
+
57
81
  - (void) setOnFastImageLoadEnd: (RCTDirectEventBlock)onFastImageLoadEnd {
58
82
  _onFastImageLoadEnd = onFastImageLoadEnd;
59
83
  if (self.hasCompleted && _onFastImageLoadEnd) {
@@ -142,6 +166,7 @@ static CFTimeInterval FFFEnteredBackgroundAt = 0;
142
166
  self.untintedImage = nil;
143
167
  super.image = image;
144
168
  }
169
+ [self updateContentMode];
145
170
  }
146
171
 
147
172
  - (void) sendOnLoad: (UIImage*)image {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-fast-image",
3
- "version": "8.6.42",
3
+ "version": "8.6.43",
4
4
  "description": "🚩 FastImage, performant React Native image component.",
5
5
  "keywords": [
6
6
  "cache",