You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50-24Lines changed: 50 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ Pull requests are very welcome!
10
10
1.[Props](#props)
11
11
1.[Methods](#methods)
12
12
1.[Properties](#properties)
13
-
1.[RTL support](#rtl-support)
14
13
1.[Example](#example)
15
14
1.[Tips and tricks](#tips-and-tricks)
15
+
1.[RTL support](#rtl-support)
16
16
1.[TODO](#todo)
17
17
1.[Credits](#credits)
18
18
@@ -26,7 +26,7 @@ You can try these examples live in **Archriss' showcase app** on [Android](https
26
26
27
27
> 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).
28
28
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.
30
30
31
31
## Breaking change
32
32
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';
75
75
76
76
## Props
77
77
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
79
79
80
80
Prop | Description | Type | Default
81
81
------ | ------ | ------ | ------
82
82
**itemWidth** | Width in pixels of your slides, **must be the same for all of them** | Number | **Required**
83
83
**sliderWidth** | Width in pixels of your slider | Number | **Required**
84
+
85
+
### Behavior
86
+
87
+
Prop | Description | Type | Default
88
+
------ | ------ | ------ | ------
84
89
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
+
------ | ------ | ------ | ------
87
101
autoplay | Trigger autoplay on mount | Boolean | `false`
88
102
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) }`
90
111
containerCustomStyle | Optional styles for Scrollview's global wrapper | ScrollView Style Object | `{}`
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`
95
113
inactiveSlideOpacity | Value of the opacity effect applied to inactive slides | Number | `1`
96
114
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`
98
115
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
+
------ | ------ | ------ | ------
101
121
onSnapToItem(slideIndex) | Callback fired when navigating to an item | Function | `undefined`
102
122
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)
*`currentIndex` Current active item (`int`, starts at 0)
144
170
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
-
157
171
## Example
158
172
You can find the following example in the [/example](https://github.com/archriss/react-native-snap-carousel/tree/master/example) folder.
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`).
0 commit comments