mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 20:15:11 +00:00
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
This commit is contained in:
parent
5d9163b87d
commit
edb523c6d7
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user