Skip to content

Commit

Permalink
feat(ios): add param for image onLoadEnd on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg authored and zealotchen0 committed Nov 23, 2023
1 parent 944e737 commit 5ae7d67
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/api/hippy-react/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import icon from './qb_icon_new.png';
| onLayout | 当元素挂载或者布局改变的时候调用,参数为: `nativeEvent: { layout: { x, y, width, height } }`,其中 `x``y` 为相对父元素的坐标位置 | `Function` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onLoad | 加载成功完成时调用此回调函数。 | `Function` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onLoadStart | 加载开始时调用。 例如, `onLoadStart={() => this.setState({ loading: true })}` | `Function` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onLoadEnd | 加载结束后,不论成功还是失败,调用此回调函数。 | `Function` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onLoadEnd | 加载结束后,不论成功还是失败,调用此回调函数。参数为:`nativeEvent: { success: number, width: number, height: number}` | `Function` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| resizeMode | 决定当组件尺寸和图片尺寸不成比例的时候如何调整图片的大小。`注意:hippy-react-web、Web-Renderer 不支持 repeat` | `enum (cover, contain, stretch, repeat, center)` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onError | 当加载错误的时候调用此回调函数,参数为 `nativeEvent: { error }` | `Function` | `Android、iOS、hippy-react-web、Web-Renderer、Voltron` |
| onProgress | 在加载过程中不断调用,参数为 `nativeEvent: { loaded: number, total: number }`, `loaded` 表示加载中的图片大小, `total` 表示图片总大小 | `Function` | `iOS、Voltron` |
Expand Down
2 changes: 1 addition & 1 deletion docs/api/hippy-vue/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
| layout | 当元素挂载或者布局改变的时候调用,参数为: `nativeEvent: { layout: { x, y, width, height } }`,其中 `x``y` 为相对父元素的坐标位置 | `Function` | `Android、iOS、Web-Renderer、Voltron` |
| load | 加载成功完成时调用此回调函数。 | `Function` | `Android、iOS、Web-Renderer、Voltron` |
| loadStart | 加载开始时调用。 | `Function` | `Android、iOS、Web-Renderer、Voltron` |
| loadEnd | 加载结束后,不论成功还是失败,调用此回调函数。 | `Function` | `Android、iOS、Web-Renderer、Voltron` |
| loadEnd | 加载结束后,不论成功还是失败,调用此回调函数。参数为:`nativeEvent: { success: number, width: number, height: number}` | `Function` | `Android、iOS、Web-Renderer、Voltron` |
| error | 当加载错误的时候调用此回调函数。| `Function` | `Android、iOS、Web-Renderer、Voltron` |
| progress | 在加载过程中不断调用,参数为 `nativeEvent: { loaded: number, total: number }`, `loaded` 表示加载中的图片大小, `total` 表示图片总大小 | `Function` | `iOS、Voltron` |
| touchstart | 触屏开始事件,最低支持版本 2.6.2,参数为 `evt: { touches: [{ clientX: number, clientY: number }] }``clientX``clientY` 分别表示点击在屏幕内的绝对位置 | `Function` | `Android、iOS、Web-Renderer、Voltron` |
Expand Down
4 changes: 2 additions & 2 deletions renderer/native/ios/renderer/component/image/HippyImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ - (void)loadImage:(UIImage *)image url:(NSString *)url error:(NSError *)error ne
_onError(@{ @"error": error.localizedDescription, @"errorCode": @(error.code), @"errorURL": url });
}
if (_onLoadEnd) {
_onLoadEnd(nil);
_onLoadEnd(@{ @"success": @0 });
}
return;
}
Expand All @@ -443,7 +443,7 @@ - (void)loadImage:(UIImage *)image url:(NSString *)url error:(NSError *)error ne
if (strongSelf.onLoad)
strongSelf.onLoad(@{ @"width": @(image.size.width), @"height": @(image.size.height), @"url": url ?: @"" });
if (strongSelf.onLoadEnd)
strongSelf.onLoadEnd(nil);
strongSelf.onLoadEnd(@{ @"success": @1, @"width": @(image.size.width), @"height": @(image.size.height) });
};

if (_blurRadius > 100 && [NSProcessInfo processInfo].physicalMemory <= 1024 * 1024 * 1000) {
Expand Down

0 comments on commit 5ae7d67

Please sign in to comment.