From edb523c6d76bbca1709e3a8fd78c0744cff5c750 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Thu, 21 Jan 2016 08:22:44 -0800 Subject: [PATCH] adjust getSize so that its doc can be shown on the page Summary: Closes https://github.com/facebook/react-native/pull/5426 Reviewed By: svcscm Differential Revision: D2848229 Pulled By: nicklockwood fb-gh-sync-id: d1cc28af889c3b1e26a098044e85e0b10032a776 --- Libraries/Image/Image.ios.js | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index e48b25baf..970ef172c 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -155,6 +155,28 @@ var Image = React.createClass({ statics: { resizeMode: ImageResizeMode, + /** + * Retrieve the width and height (in pixels) of an image prior to displaying it. + * This method can fail if the image cannot be found, or fails to download. + * + * In order to retrieve the image dimensions, the image may first need to be + * loaded or downloaded, after which it will be cached. This means that in + * principle you could use this method to preload images, however it is not + * optimized for that purpose, and may in future be implemented in a way that + * does not fully load/download the image data. A proper, supported way to + * preload images will be provided as a separate API. + * + * @platform ios + */ + getSize: function( + uri: string, + success: (width: number, height: number) => void, + failure: (error: any) => void, + ) { + ImageViewManager.getSize(uri, success, failure || function() { + console.warn('Failed to get size for image: ' + uri); + }); + } }, mixins: [NativeMethodsMixin], @@ -214,27 +236,5 @@ var RCTImageView = requireNativeComponent('RCTImageView', Image); var RCTNetworkImageView = NetworkImageViewManager ? requireNativeComponent('RCTNetworkImageView', Image) : RCTImageView; var RCTVirtualImage = requireNativeComponent('RCTVirtualImage', Image); -/** - * Retrieve the width and height (in pixels) of an image prior to displaying it. - * This method can fail if the image cannot be found, or fails to download. - * - * In order to retrieve the image dimensions, the image may first need to be - * loaded or downloaded, after which it will be cached. This means that in - * principle you could use this method to preload images, however it is not - * optimized for that purpose, and may in future be implemented in a way that - * does not fully load/download the image data. A proper, supported way to - * preload images will be provided as a separate API. - * - * @platform ios - */ -Image.getSize = function( - uri: string, - success: (width: number, height: number) => void, - failure: (error: any) => void, -) { - ImageViewManager.getSize(uri, success, failure || function() { - console.warn('Failed to get size for image: ' + uri); - }); -}; module.exports = Image;