Skip to content

Commit

Permalink
support key extractor for version 3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
namlh4 committed Feb 27, 2020
1 parent de9c133 commit 362b4e1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports={
"tabWidth": 2,
"singleQuote": true
};
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ import Carousel from 'react-native-anchor-carousel';
| ------ | ------ | ------| -----| ----|
| data | Array of data for rendering | Array | [] | **Yes**|
|renderItems | take each item from data and renders it. Function receives one agrument `{item,index}` and must return as React.Element | Function | () => {} | **Yes** |
| initialIndex | Initial starting focused item of list | Number| 0 | No |
| initialIndex | Initial starting focused item of list | Number | 0 | No |
| keyExtractor | Key extractor for each item of list | Function | (item, index) => index.toString() | No |
| onScrollEnd | Fired while scrollview end of scrolling | Function | ()=> {} | No |
| pagingEnable | Enable or disable autor scroll to closest item | Boolean | False | No |
| containerWidth | Width of the carousel container box | number | Screen width | **Yes** |
| containerWidth | Width of the carousel container box | Number | Screen width | **Yes** |
| itemWidth | Width of each item in carousel | Number | 90% of screen width | **Yes** |
| separatorWidth| Width of separator in carousel (cause it only support horizontal side at the present time)| Number | 10 | No
| inActiveScale | Value of the scale effect applied to inactive item | Number | 0.85 | No |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-anchor-carousel",
"version": "3.1.1",
"version": "3.1.2",
"description": "a simple swipeable carousel which anchor two sides",
"main": "src/index.js",
"directories": {
Expand Down
5 changes: 4 additions & 1 deletion src/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class Carousel extends Component {
itemWidth,
containerWidth,
initialIndex,
keyExtractor,
...otherProps
} = this.props;
return (
Expand All @@ -213,7 +214,7 @@ class Carousel extends Component {
data={data}
decelerationRate={0}
automaticallyAdjustContentInsets={false}
keyExtractor={(item, index) => index.toString()}
keyExtractor={keyExtractor}
ref={(ref) => (this._scrollView = ref)}
renderItem={this.renderItemContainer}
style={[styles.container, { width: containerWidth }, style]}
Expand All @@ -238,6 +239,7 @@ Carousel.propTypes = {
itemContainerStyle: ViewPropTypes.style,
inActiveScale: PropTypes.number,
inActiveOpacity: PropTypes.number,
keyExtractor: PropTypes.func,
renderItem: PropTypes.func,
onScrollEnd: PropTypes.func,
pagingEnable: PropTypes.bool,
Expand All @@ -263,6 +265,7 @@ Carousel.defaultProps = {
pagingEnable: true,
minScrollDistance: 25,
itemContainerStyle: {},
keyExtractor: (item, index) => index.toString(),
renderItem: () => {},
onScrollEnd: () => {},
onScrollBeginDrag: () => {},
Expand Down

0 comments on commit 362b4e1

Please sign in to comment.