mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Change Image load event size info from logical size to pixel (#45198)
Summary: Fixes https://github.com/facebook/react-native/issues/45188. This fixes old arch. fabric fix may wait until https://github.com/facebook/react-native/issues/44918. ## Changelog: [IOS] [BREAKING] - Change Image load event size info from logical size to pixel Pull Request resolved: https://github.com/facebook/react-native/pull/45198 Test Plan: Android/iOS return the same size . ``` <Image style={{width: '100%', height: '100%'}} source={{ uri: 'https://image-placeholder.com/images/actual-size/75x75.png', }} resizeMode={'cover'} onLoad={e => { console.log( `RNImage:${Platform.OS} load JPEG image from url`, e.nativeEvent, ); }} /> ``` Reviewed By: cortinico Differential Revision: D67735347 Pulled By: cipolleschi fbshipit-source-id: 72422d8c15e4cc6313215bf6d9a2c1e6b5a235ad
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b10491a3c4
commit
09995fc874
@@ -41,8 +41,8 @@ static NSDictionary *onLoadParamsForSource(RCTImageSource *source)
|
||||
{
|
||||
NSDictionary *dict = @{
|
||||
@"uri" : source.request.URL.absoluteString,
|
||||
@"width" : @(source.size.width),
|
||||
@"height" : @(source.size.height),
|
||||
@"width" : @(source.size.width * source.scale),
|
||||
@"height" : @(source.size.height * source.scale),
|
||||
};
|
||||
return @{@"source" : dict};
|
||||
}
|
||||
@@ -406,7 +406,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
|
||||
}
|
||||
} else {
|
||||
if (strongSelf->_onLoad) {
|
||||
RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:source.scale];
|
||||
RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:image.scale];
|
||||
strongSelf->_onLoad(onLoadParamsForSource(sourceLoaded));
|
||||
}
|
||||
if (strongSelf->_onLoadEnd) {
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@ void ImageEventEmitter::onLoad(const ImageSource& source) const {
|
||||
dispatchEvent("load", [source](jsi::Runtime& runtime) {
|
||||
auto src = jsi::Object(runtime);
|
||||
src.setProperty(runtime, "uri", source.uri);
|
||||
src.setProperty(runtime, "width", source.size.width);
|
||||
src.setProperty(runtime, "height", source.size.height);
|
||||
src.setProperty(runtime, "width", source.size.width * source.scale);
|
||||
src.setProperty(runtime, "height", source.size.height * source.scale);
|
||||
auto payload = jsi::Object(runtime);
|
||||
payload.setProperty(runtime, "source", src);
|
||||
return payload;
|
||||
|
||||
Reference in New Issue
Block a user