@@ -35,6 +35,8 @@ The best Swiper component for React Native.
35
35
36
36
- [x] Custom pagination style
37
37
38
+ - [x] State inject
39
+
38
40
## Changelogs
39
41
40
42
- ** [ v1.2.2] **
@@ -167,7 +169,7 @@ AppRegistry.registerComponent('swiper', () => swiper)
167
169
168
170
#### Basic
169
171
170
- | Prop | Default | Type | Describe |
172
+ | Prop | Default | Type | Description |
171
173
| :------------ | :---------------:| :---------------:| :-----|
172
174
| horizontal | true | ` bool ` | If ` true ` , the scroll view's children are arranged horizontally in a row instead of vertically in a column. |
173
175
| loop | true | ` bool ` | Set to ` true ` to enable continuous loop mode. |
@@ -177,33 +179,33 @@ AppRegistry.registerComponent('swiper', () => swiper)
177
179
178
180
#### Custom basic style & content
179
181
180
- | Prop | Default | Type | Describe |
182
+ | Prop | Default | Type | Description |
181
183
| :------------ | :---------------:| :---------------:| :-----|
182
184
| width | - | ` number ` | If no specify default enable fullscreen mode by ` flex: 1 ` . |
183
185
| height | - | ` number ` | If no specify default fullscreen mode by ` flex: 1 ` . |
184
186
| style | {...} | ` style ` | See default style in source. |
185
187
186
188
#### Pagination
187
189
188
- | Prop | Default | Type | Describe |
190
+ | Prop | Default | Type | Description |
189
191
| :------------ | :---------------:| :---------------:| :-----|
190
192
| showsPagination | true | ` bool ` | Set to ` true ` make pagination visible. |
191
193
| paginationStyle | {...} | ` style ` | Custom styles will merge with the default styles. |
192
- | renderPagination | - | ` function ` | Complete control how to render pagination with two params (` index ` , ` total ` ) ref to ` this.state.index ` / ` this.state.total ` , For example: show numbers instead of dots. |
194
+ | renderPagination | - | ` function ` | Complete control how to render pagination with three params (` index ` , ` total ` , ` context ` ) ref to ` this.state.index ` / ` this.state.total ` / ` this ` , For example: show numbers instead of dots. |
193
195
| dot | ` <View style={{backgroundColor:'rgba(0,0,0,.2)', width: 8, height: 8,borderRadius: 4, marginLeft: 3, marginRight: 3, marginTop: 3, marginBottom: 3,}} /> ` | ` element ` | Allow custom the dot element. |
194
196
| activeDot | ` <View style={{backgroundColor: '#007aff', width: 8, height: 8, borderRadius: 4, marginLeft: 3, marginRight: 3, marginTop: 3, marginBottom: 3,}} /> ` | ` element ` | Allow custom the active-dot element. |
195
197
196
198
#### Autoplay
197
199
198
- | Prop | Default | Type | Describe |
200
+ | Prop | Default | Type | Description |
199
201
| :------------ | :---------------:| :---------------:| :-----|
200
202
| autoplay | true | ` bool ` | Set to ` true ` enable auto play mode. |
201
203
| autoplayTimeout | 2.5 | ` number ` | Delay between auto play transitions (in second). |
202
204
| autoplayDirection | true | ` bool ` | Cycle direction control. |
203
205
204
206
#### Control buttons
205
207
206
- | Prop | Default | Type | Describe |
208
+ | Prop | Default | Type | Description |
207
209
| :------------ | :---------------:| :---------------:| :-----|
208
210
| showsButtons | true | ` bool ` | Set to ` true ` make control buttons visible. |
209
211
| buttonWrapperStyle | ` {backgroundColor: 'transparent', flexDirection: 'row', position: 'absolute', top: 0, left: 0, flex: 1, paddingHorizontal: 10, paddingVertical: 10, justifyContent: 'space-between', alignItems: 'center'} ` | ` style ` | Custom styles. |
@@ -212,14 +214,14 @@ AppRegistry.registerComponent('swiper', () => swiper)
212
214
213
215
#### Props of Children
214
216
215
- | Prop | Default | Type | Describe |
217
+ | Prop | Default | Type | Description |
216
218
| :------------ | :---------------:| :---------------:| :-----|
217
219
| style | {...} | ` style ` | Custom styles will merge with the default styles. |
218
220
| title | {<Text numberOfLines ={1} >...</Text >} | ` element ` | If this parameter is not specified, will not render the title. |
219
221
220
222
#### Basic props of ` <ScrollView /> `
221
223
222
- | Prop | Default | Type | Describe |
224
+ | Prop | Default | Type | Description |
223
225
| :------------ | :---------------:| :---------------:| :-----|
224
226
| horizontal | true | ` bool ` | If ` true ` , the scroll view's children are arranged horizontally in a row instead of vertically in a column. |
225
227
| pagingEnabled | true | ` bool ` | If true, the scroll view stops on multiples of the scroll view's size when scrolling. This can be used for horizontal pagination. |
@@ -234,16 +236,34 @@ AppRegistry.registerComponent('swiper', () => swiper)
234
236
235
237
#### Supported ScrollResponder
236
238
237
- | Prop | Default | Type | Describe |
239
+ | Prop | Params | Type | Description |
238
240
| :------------ | :---------------:| :---------------:| :-----|
239
- | onMomentumScrollBegin | - | ` function ` | When animation begins after letting up |
240
- | onMomentumScrollEnd | - | ` function ` | Makes no sense why this occurs first during bounce |
241
- | onTouchStartCapture | - | ` function ` | Immediately after ` onMomentumScrollEnd ` |
242
- | onTouchStart | - | ` function ` | Same, but bubble phase |
243
- | onTouchEnd | - | ` function ` | You could hold the touch start for a long time |
244
- | onResponderRelease | - | ` function ` | When lifting up - you could pause forever before * lifting |
245
-
246
- > @see : https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollResponder.js
241
+ | onMomentumScrollBegin | ` e ` / ` state ` / ` context ` | ` function ` | When animation begins after letting up |
242
+ | onMomentumScrollEnd | ` e ` / ` state ` / ` context ` | ` function ` | Makes no sense why this occurs first during bounce |
243
+ | onTouchStartCapture | ` e ` / ` state ` / ` context ` | ` function ` | Immediately after ` onMomentumScrollEnd ` |
244
+ | onTouchStart | ` e ` / ` state ` / ` context ` | ` function ` | Same, but bubble phase |
245
+ | onTouchEnd | ` e ` / ` state ` / ` context ` | ` function ` | You could hold the touch start for a long time |
246
+ | onResponderRelease | ` e ` / ` state ` / ` context ` | ` function ` | When lifting up - you could pause forever before * lifting |
247
+
248
+ > Note: each ScrollResponder be injected with two params: ` state ` and ` context ` , you can get ` state ` and ` this ` (ref to swiper's context) from params, for example:
249
+
250
+ ``` jsx
251
+ var swiper = React .createClass ({
252
+ _onMomentumScrollEnd : function (e , state , context ) {
253
+ console .log (state, context .state )
254
+ },
255
+ render : function () {
256
+ return (
257
+ < Swiper style= {styles .wrapper }
258
+ onMomentumScrollEnd = {this ._onMomentumScrollEnd }
259
+ ...
260
+ < / Swiper>
261
+ )
262
+ }
263
+ })
264
+ ```
265
+
266
+ > More ScrollResponder info, see: https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollResponder.js
247
267
248
268
### Examples
249
269
0 commit comments