Skip to content

Commit ff236ce

Browse files
author
bd-arc
committed
doc(README): organize props to improve readability
1 parent a677bd2 commit ff236ce

File tree

1 file changed

+50
-24
lines changed

1 file changed

+50
-24
lines changed

README.md

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Pull requests are very welcome!
1010
1. [Props](#props)
1111
1. [Methods](#methods)
1212
1. [Properties](#properties)
13-
1. [RTL support](#rtl-support)
1413
1. [Example](#example)
1514
1. [Tips and tricks](#tips-and-tricks)
15+
1. [RTL support](#rtl-support)
1616
1. [TODO](#todo)
1717
1. [Credits](#credits)
1818

@@ -26,7 +26,7 @@ You can try these examples live in **Archriss' showcase app** on [Android](https
2626

2727
> Since it has been asked multiple times, please note that **we do not plan on Open-Sourcing the code of our showcase app**. Still, we've put together [an example](#example) for you to play with, and you can find some insight about our map implementation [in this comment](https://github.com/archriss/react-native-snap-carousel/issues/11#issuecomment-265147385).
2828
29-
App currently uses version 1.4.0 of the plugin. Especially, this means that you should expect **slider's layout to break with RTL devices** (see #38) since support was added in version 2.1.0.
29+
App currently uses version 1.4.0 of the plugin. Especially, this means that you should expect **slider's layout to break with RTL devices** (see [#38](https://github.com/archriss/react-native-snap-carousel/issues/38)) since support was added in version 2.1.0.
3030

3131
## Breaking change
3232
Since version 2.0.0, items are now **direct children of the <Carousel> component**. As a result, props `items` and `renderItem` have been removed.
@@ -75,31 +75,57 @@ import Carousel from 'react-native-snap-carousel';
7575

7676
## Props
7777

78-
> In addition to these props, you can provide **any prop from the [ScrollView component](https://facebook.github.io/react-native/docs/scrollview.html)**.
78+
### Required
7979

8080
Prop | Description | Type | Default
8181
------ | ------ | ------ | ------
8282
**itemWidth** | Width in pixels of your slides, **must be the same for all of them** | Number | **Required**
8383
**sliderWidth** | Width in pixels of your slider | Number | **Required**
84+
85+
### Behavior
86+
87+
Prop | Description | Type | Default
88+
------ | ------ | ------ | ------
8489
activeSlideOffset | From slider's center, minimum slide distance to be scrolled before being set to active | Number | `25`
85-
animationFunc | Animated animation to use. Provide the name of the method | String | `timing`
86-
animationOptions | Animation options to be merged with the default ones. Can be used w/ animationFunc | Object | `{ easing: Easing.elastic(1) }`
90+
enableMomentum | See [momentum](#momentum) | Boolean | `false`
91+
enableSnap | If enabled, releasing the touch will scroll to the center of the nearest/active item | Number | `true`
92+
firstItem | Index of the first item to display | Number | `0`
93+
shouldOptimizeUpdates | whether to implement a `shouldComponentUpdate` strategy to minimize updates | Boolean | `true`
94+
snapOnAndroid | Snapping on android is kinda choppy, especially when swiping quickly so you can disable it | Boolean | `true`
95+
swipeThreshold | Delta x when swiping to trigger the snap | Number | `20`
96+
97+
### Autoplay
98+
99+
Prop | Description | Type | Default
100+
------ | ------ | ------ | ------
87101
autoplay | Trigger autoplay on mount | Boolean | `false`
88102
autoplayDelay | Delay before enabling autoplay on startup & after releasing the touch | Number | `5000`
89-
autoplayInterval | Delay in ms until navigating to the next item | `3000`
103+
autoplayInterval | Delay in ms until navigating to the next item | Number | `3000`
104+
105+
### Style and animation
106+
107+
Prop | Description | Type | Default
108+
------ | ------ | ------ | ------
109+
animationFunc | Animated animation to use. Provide the name of the method | String | `timing`
110+
animationOptions | Animation options to be merged with the default ones. Can be used w/ animationFunc | Object | `{ easing: Easing.elastic(1) }`
90111
containerCustomStyle | Optional styles for Scrollview's global wrapper | ScrollView Style Object | `{}`
91112
contentContainerCustomStyle | Optional styles for Scrollview's items container | ScrollView Style Object | `{}`
92-
enableMomentum | See [momentum](#momentum) | Boolean | `false`
93-
enableSnap | If enabled, releasing the touch will scroll to the center of the nearest/active item | Number | `true`
94-
firstItem | Index of the first item to display | Number | `0`
95113
inactiveSlideOpacity | Value of the opacity effect applied to inactive slides | Number | `1`
96114
inactiveSlideScale | Value of the 'scale' transform applied to inactive slides | Number | `0.9`
97-
shouldOptimizeUpdates | whether to implement a `shouldComponentUpdate` strategy to minimize updates | Boolean | `true`
98115
slideStyle | Optional style for each item's container (the one whose scale and opacity are animated) | Animated View Style Object | {}
99-
snapOnAndroid | Snapping on android is kinda choppy, especially when swiping quickly so you can disable it | Boolean | `true`
100-
swipeThreshold | Delta x when swiping to trigger the snap | Number | `20`
116+
117+
### Callbacks
118+
119+
Prop | Description | Type | Default
120+
------ | ------ | ------ | ------
101121
onSnapToItem(slideIndex) | Callback fired when navigating to an item | Function | `undefined`
102122

123+
### `ScrollView`
124+
125+
In addition to these props, you can use **any prop from the [ScrollView component](https://facebook.github.io/react-native/docs/scrollview.html)**.
126+
127+
Here are a few useful ones:`removeClippedSubviews`, `showsHorizontalScrollIndicator`, `overScrollMode` (android), `bounces` (ios), `decelerationRate` (ios), `scrollEventThrottle` (ios)
128+
103129
## Methods
104130

105131
### Reference to the component
@@ -142,18 +168,6 @@ onPress={() => { this.refs.carousel.snapToNext(); }}
142168
143169
* `currentIndex` Current active item (`int`, starts at 0)
144170

145-
## RTL support
146-
147-
### Experimental feature
148-
149-
Since version 2.1.0, the plugin is compatible with RTL layouts. Our implementation relies on miscellaneous hacks that work around a [React Native bug](https://github.com/facebook/react-native/issues/11960) with horizontal `ScrollView`.
150-
151-
As such, this feature should be considered experimental since it might break with newer versions of React Native.
152-
153-
### Known issue
154-
155-
There is one kown issue with RTL layouts: during init, the last slide will shortly be seen. You can work around this by delaying slider's visibility with a small timer (FYI, version 0.43.0 of React Native [introduced a `display` style prop](https://github.com/facebook/react-native/commit/4d69f4b2d1cf4f2e8265fe5758f28086f1b67500) that could either be set to `flex` or `none`).
156-
157171
## Example
158172
You can find the following example in the [/example](https://github.com/archriss/react-native-snap-carousel/tree/master/example) folder.
159173

@@ -193,6 +207,18 @@ const styles = Stylesheet.create({
193207

194208
```
195209
210+
## RTL support
211+
212+
### Experimental feature
213+
214+
Since version 2.1.0, the plugin is compatible with RTL layouts. Our implementation relies on miscellaneous hacks that work around a [React Native bug](https://github.com/facebook/react-native/issues/11960) with horizontal `ScrollView`.
215+
216+
As such, this feature should be considered experimental since it might break with newer versions of React Native.
217+
218+
### Known issue
219+
220+
There is one kown issue with RTL layouts: during init, the last slide will shortly be seen. You can work around this by delaying slider's visibility with a small timer (FYI, version 0.43.0 of React Native [introduced a `display` style prop](https://github.com/facebook/react-native/commit/4d69f4b2d1cf4f2e8265fe5758f28086f1b67500) that could either be set to `flex` or `none`).
221+
196222
## TODO
197223
198224
- [ ] Implement 'loop' mode

0 commit comments

Comments
 (0)