Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions ImageSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type Slide = {

type PropsType = {
images: Array<number | string>,
startString: string,
imageKey: string,
style?: any,
loop?: boolean,
loopBothSides?: boolean,
Expand Down Expand Up @@ -185,25 +187,25 @@ class ImageSlider extends Component<PropsType, StateType> {

_renderImage = (image: any, index: number) => {
const { width } = Dimensions.get('window');
const { onPress, customSlide } = this.props;
const { onPress, customSlide, startString = '', imageKey = '', imageStyle={}, resizeMode='cover' } = this.props;
const offset = { marginLeft: index === -1 ? -width : 0 };
const imageStyle = [styles.image, { width }, offset];
const imgStyle = [styles.image, { width }, offset, imageStyle];

if (customSlide) {
return customSlide({ item: image, style: imageStyle, index, width });
return customSlide({ item: image, style: imgStyle, index, width });
}

const imageObject = typeof image === 'string' ? { uri: image } : image;
const imageObject = typeof image === 'string' ? image.includes('file:/') ? { uri: image } : { uri: startString + image } : typeof image === 'object' ? { uri: startString + image[imageKey] } : image;

const imageComponent = (
<Image key={index} source={imageObject} style={[imageStyle]} />
<Image key={index} source={imageObject} style={[imgStyle]} resizeMode={resizeMode}/>
);

if (onPress) {
return (
<TouchableOpacity
key={index}
style={[imageStyle, offset]}
style={[imgStyle, offset]}
onPress={() => onPress && onPress({ image, index })}
delayPressIn={200}
>
Expand Down Expand Up @@ -294,7 +296,6 @@ const styles = StyleSheet.create({
backgroundColor: '#222',
},
image: {
width: 200,
height: '100%',
},
buttons: {
Expand Down