mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-23 04:00:04 +08:00
Correct the Image docs
This commit is contained in:
@@ -46,7 +46,7 @@ Invoked when load either succeeds or fails,
|
||||
|
||||
Invoked on load start.
|
||||
|
||||
**resizeMode**: oneOf('center', 'contain', 'cover', 'none', 'repeat', 'stretch') = 'stretch'
|
||||
**resizeMode**: oneOf('center', 'contain', 'cover', 'none', 'repeat', 'stretch') = 'cover'
|
||||
|
||||
Determines how to resize the image when the frame doesn't match the raw image
|
||||
dimensions.
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import keyMirror from 'fbjs/lib/keyMirror';
|
||||
|
||||
const ImageResizeMode = keyMirror({
|
||||
center: null,
|
||||
contain: null,
|
||||
cover: null,
|
||||
none: null,
|
||||
repeat: null,
|
||||
stretch: null
|
||||
});
|
||||
const ImageResizeMode = {
|
||||
center: 'center',
|
||||
contain: 'contain',
|
||||
cover: 'cover',
|
||||
none: 'none',
|
||||
repeat: 'repeat',
|
||||
stretch: 'stretch'
|
||||
};
|
||||
|
||||
module.exports = ImageResizeMode;
|
||||
|
||||
@@ -4,7 +4,6 @@ import BaseComponentPropTypes from '../../propTypes/BaseComponentPropTypes';
|
||||
import createDOMElement from '../../modules/createDOMElement';
|
||||
import ImageResizeMode from './ImageResizeMode';
|
||||
import ImageStylePropTypes from './ImageStylePropTypes';
|
||||
import resolveAssetSource from './resolveAssetSource';
|
||||
import StyleSheet from '../../apis/StyleSheet';
|
||||
import StyleSheetPropType from '../../propTypes/StyleSheetPropType';
|
||||
import View from '../View';
|
||||
@@ -23,6 +22,10 @@ const ImageSourcePropType = PropTypes.oneOfType([
|
||||
PropTypes.string
|
||||
]);
|
||||
|
||||
const resolveAssetSource = (source) => {
|
||||
return ((typeof source === 'object') ? source.uri : source) || null;
|
||||
};
|
||||
|
||||
class Image extends Component {
|
||||
static displayName = 'Image';
|
||||
|
||||
@@ -35,7 +38,7 @@ class Image extends Component {
|
||||
onLoad: PropTypes.func,
|
||||
onLoadEnd: PropTypes.func,
|
||||
onLoadStart: PropTypes.func,
|
||||
resizeMode: PropTypes.oneOf([ 'center', 'contain', 'cover', 'none', 'repeat', 'stretch' ]),
|
||||
resizeMode: PropTypes.oneOf(Object.keys(ImageResizeMode)),
|
||||
source: ImageSourcePropType,
|
||||
style: StyleSheetPropType(ImageStylePropTypes)
|
||||
};
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
function resolveAssetSource(source) {
|
||||
return ((typeof source === 'object') ? source.uri : source) || null;
|
||||
}
|
||||
|
||||
module.exports = resolveAssetSource;
|
||||
Reference in New Issue
Block a user