mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Add onLoadX support on Android
Summary: ~~This is a WIP, just finished the first bit and wanted to get some feedback to see if this approach seems appropriate, as I haven't done a lot of Android development.~~ Looks ready for review now. Closes https://github.com/facebook/react-native/pull/3791 Reviewed By: svcscm Differential Revision: D2672262 Pulled By: mkonicek fb-gh-sync-id: 1e8f1cc6658fb719a68f7da455f30a7c9b1db730
This commit is contained in:
committed by
facebook-github-bot-5
parent
b65f1f2234
commit
ae09a10c95
@@ -56,6 +56,7 @@ var ImageViewAttributes = merge(ReactNativeViewAttributes.UIView, {
|
||||
resizeMode: true,
|
||||
progressiveRenderingEnabled: true,
|
||||
fadeDuration: true,
|
||||
shouldNotifyLoadEvents: true,
|
||||
});
|
||||
|
||||
var Image = React.createClass({
|
||||
@@ -75,7 +76,18 @@ var Image = React.createClass({
|
||||
]).isRequired,
|
||||
progressiveRenderingEnabled: PropTypes.bool,
|
||||
fadeDuration: PropTypes.number,
|
||||
style: StyleSheetPropType(ImageStylePropTypes),
|
||||
/**
|
||||
* Invoked on load start
|
||||
*/
|
||||
onLoadStart: PropTypes.func,
|
||||
/**
|
||||
* Invoked when load completes successfully
|
||||
*/
|
||||
onLoad: PropTypes.func,
|
||||
/**
|
||||
* Invoked when load either succeeds or fails
|
||||
*/
|
||||
onLoadEnd: PropTypes.func,
|
||||
/**
|
||||
* Used to locate this view in end-to-end tests.
|
||||
*/
|
||||
@@ -137,9 +149,11 @@ var Image = React.createClass({
|
||||
if (source && source.uri) {
|
||||
var {width, height} = source;
|
||||
var style = flattenStyle([{width, height}, styles.base, this.props.style]);
|
||||
var {onLoadStart, onLoad, onLoadEnd} = this.props;
|
||||
|
||||
var nativeProps = merge(this.props, {
|
||||
style,
|
||||
shouldNotifyLoadEvents: !!(onLoadStart || onLoad || onLoadEnd),
|
||||
src: source.uri,
|
||||
});
|
||||
|
||||
@@ -186,6 +200,7 @@ var cfg = {
|
||||
defaultImageSrc: true,
|
||||
imageTag: true,
|
||||
progressHandlerRegistered: true,
|
||||
shouldNotifyLoadEvents: true,
|
||||
},
|
||||
};
|
||||
var RKImage = requireNativeComponent('RCTImageView', Image, cfg);
|
||||
|
||||
@@ -113,7 +113,6 @@ var Image = React.createClass({
|
||||
onLayout: PropTypes.func,
|
||||
/**
|
||||
* Invoked on load start
|
||||
* @platform ios
|
||||
*/
|
||||
onLoadStart: PropTypes.func,
|
||||
/**
|
||||
@@ -128,12 +127,10 @@ var Image = React.createClass({
|
||||
onError: PropTypes.func,
|
||||
/**
|
||||
* Invoked when load completes successfully
|
||||
* @platform ios
|
||||
*/
|
||||
onLoad: PropTypes.func,
|
||||
/**
|
||||
* Invoked when load either succeeds or fails
|
||||
* @platform ios
|
||||
*/
|
||||
onLoadEnd: PropTypes.func,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user