0.1.3 • Published 8 years ago

react-native-image-carousell v0.1.3

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

react-native-image-carousell

A component for image gallery carousell like iOS Photos app

Features

  • Has a bottom preview for near photos and will scroll responsively
  • Support zoom
  • Will hide preview when zoomScale > 1
  • Currently iOS support only, check #2

Installation

npm install --save react-native-image-carousell

Usage

import ImageCarousell from 'react-native-image-carousell';

class Example extends React.Component {
  constructor(props) {
    super(props);
    const dataSource = new ListView.DataSource({
      rowHasChanged: (r1, r2) => r1 !== r2,
    });
    this.state = {
      dataSource: dataSource.cloneWithRows([
        require('./images/1.png'),
        require('./images/2.png'),
        require('./images/3.png'),
        require('./images/4.png'),
        require('./images/5.png'),
        require('./images/6.png'),
        require('./images/7.png'),
        require('./images/8.png'),
        require('./images/9.png'),
        require('./images/10.png'),
      ]),
    };
  }
  
  render() {
    return (
      <View style={styles.container}>
        <ImageCarousell
          dataSource={this.state.dataSource}
        />
      </View>
    );
  }
}

Properties

PropTypeDescriptionRequired
dataSourceListView.DataSourceThe image data sourcetrue
initialIndexnumberThe initial image to show based on dataSource index (Default 0)
showPreviewboolTo show bottom image preview (Default true)
previewImageSizenumberPreview image size (Default 80)
widthnumberWidth for ImageCarousell (Default is Dimensions.get('window').width
heightnumberHeight for ImageCarousell (Default is Dimensions.get('window').height
styleView.propTypes.styleCustom style for ImageCarousell
previewContainerStyleView.propTypes.styleCustom style for bottom preview container
imageStyleView.propTypes.styleCustom style for Image
previewImageStyleView.propTypes.styleCustom style for bottom preview image
getImageSourceFromDataSourcefunctionThe getter for each dataSource row. (Default is (row) => row.You could however to use (row) => { uri: row.get('image') } if you use Immutable.js
renderScrollComponentfunctionCustom ScrollView component for ListView

Example

Check Example

License

MIT