Add fallback option.
This commit is contained in:
parent
400232767b
commit
30a2ff7909
20
src/index.js
20
src/index.js
|
@ -31,11 +31,30 @@ class FastImage extends Component {
|
||||||
onLoadEnd,
|
onLoadEnd,
|
||||||
style,
|
style,
|
||||||
children,
|
children,
|
||||||
|
fallback,
|
||||||
...props
|
...props
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const resolvedSource = resolveAssetSource(source)
|
const resolvedSource = resolveAssetSource(source)
|
||||||
|
|
||||||
|
if (fallback) {
|
||||||
|
return (
|
||||||
|
<View style={[style, styles.imageContainer]} ref={this.captureRef}>
|
||||||
|
<FastImageView
|
||||||
|
{...props}
|
||||||
|
style={StyleSheet.absoluteFill}
|
||||||
|
source={resolvedSource}
|
||||||
|
onLoadStart={onLoadStart}
|
||||||
|
onProgress={onProgress}
|
||||||
|
onLoad={onLoad}
|
||||||
|
onError={onError}
|
||||||
|
onLoadEnd={onLoadEnd}
|
||||||
|
/>
|
||||||
|
{children}
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[style, styles.imageContainer]} ref={this.captureRef}>
|
<View style={[style, styles.imageContainer]} ref={this.captureRef}>
|
||||||
<FastImageView
|
<FastImageView
|
||||||
|
@ -95,6 +114,7 @@ FastImage.propTypes = {
|
||||||
onLoad: PropTypes.func,
|
onLoad: PropTypes.func,
|
||||||
onError: PropTypes.func,
|
onError: PropTypes.func,
|
||||||
onLoadEnd: PropTypes.func,
|
onLoadEnd: PropTypes.func,
|
||||||
|
fallback: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
const FastImageView = requireNativeComponent('FastImageView', FastImage, {
|
const FastImageView = requireNativeComponent('FastImageView', FastImage, {
|
||||||
|
|
Loading…
Reference in New Issue