@@ -219,20 +219,24 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
219
219
* @param {object } e native event
220
220
*/
221
221
onScrollBegin : function onScrollBegin ( e ) {
222
+ var _this2 = this ;
223
+
222
224
// update scroll state
223
225
this . setState ( {
224
226
isScrolling : true
225
227
} ) ;
226
228
227
- this . props . onScrollBeginDrag && this . props . onScrollBeginDrag . call ( this , e ) ;
229
+ this . setTimeout ( function ( ) {
230
+ _this2 . props . onScrollBeginDrag && _this2 . props . onScrollBeginDrag . call ( _this2 , e ) ;
231
+ } ) ;
228
232
} ,
229
233
230
234
/**
231
235
* Scroll end handle
232
236
* @param {object } e native event
233
237
*/
234
238
onScrollEnd : function onScrollEnd ( e ) {
235
- var _this2 = this ;
239
+ var _this3 = this ;
236
240
237
241
// update scroll state
238
242
this . setState ( {
@@ -241,12 +245,14 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
241
245
242
246
this . updateIndex ( e . nativeEvent . contentOffset , this . state . dir ) ;
243
247
248
+ // Note: `this.setState` is async, so I call the `onMomentumScrollEnd`
249
+ // in setTimeout to ensure synchronous update `index`
244
250
this . setTimeout ( function ( ) {
245
- _this2 . autoplay ( ) ;
246
- } ) ;
251
+ _this3 . autoplay ( ) ;
247
252
248
- // if `onMomentumScrollEnd` registered will be called here
249
- this . props . onMomentumScrollEnd && this . props . onMomentumScrollEnd . call ( this , e ) ;
253
+ // if `onMomentumScrollEnd` registered will be called here
254
+ _this3 . props . onMomentumScrollEnd && _this3 . props . onMomentumScrollEnd . call ( _this3 , e ) ;
255
+ } ) ;
250
256
} ,
251
257
252
258
/**
@@ -267,6 +273,7 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
267
273
} // Note: if touch very very quickly and continuous,
268
274
// the variation of `index` more than 1.
269
275
index = index + diff / step ;
276
+
270
277
if ( this . props . loop ) {
271
278
if ( index <= - 1 ) {
272
279
index = state . total - 1 ;
@@ -351,7 +358,7 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
351
358
} ,
352
359
353
360
renderButtons : function renderButtons ( ) {
354
- var _this3 = this ;
361
+ var _this4 = this ;
355
362
356
363
var nextButton = this . props . nextButton || _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2 [ 'default' ] . createElement (
357
364
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity . Text ,
@@ -371,7 +378,7 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
371
378
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity2 [ 'default' ] . createElement (
372
379
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity . TouchableOpacity ,
373
380
{ onPress : function ( ) {
374
- return ! ( ! _this3 . props . loop && _this3 . state . index == 0 ) && _this3 . scrollTo . call ( _this3 , - 1 ) ;
381
+ return ! ( ! _this4 . props . loop && _this4 . state . index == 0 ) && _this4 . scrollTo . call ( _this4 , - 1 ) ;
375
382
} } ,
376
383
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity2 [ 'default' ] . createElement (
377
384
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity . View ,
@@ -382,7 +389,7 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
382
389
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity2 [ 'default' ] . createElement (
383
390
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity . TouchableOpacity ,
384
391
{ onPress : function ( ) {
385
- return ! ( ! _this3 . props . loop && _this3 . state . index == _this3 . state . total - 1 ) && _this3 . scrollTo . call ( _this3 , 1 ) ;
392
+ return ! ( ! _this4 . props . loop && _this4 . state . index == _this4 . state . total - 1 ) && _this4 . scrollTo . call ( _this4 , 1 ) ;
386
393
} } ,
387
394
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity2 [ 'default' ] . createElement (
388
395
_React$StyleSheet$Text$View$ScrollView$TouchableOpacity . View ,
0 commit comments