@@ -15,6 +15,10 @@ import {
15
15
ActivityIndicator
16
16
} from 'react-native'
17
17
18
+ import ViewPagerAndroid from '@react-native-community/viewpager' ;
19
+
20
+ const { width, height } = Dimensions . get ( 'window' )
21
+
18
22
/**
19
23
* Default styles
20
24
* @type {StyleSheetPropType }
@@ -196,13 +200,14 @@ export default class extends Component {
196
200
autoplayTimer = null
197
201
loopJumpTimer = null
198
202
199
- componentWillReceiveProps ( nextProps ) {
200
- if ( ! nextProps . autoplay && this . autoplayTimer )
203
+ componentWillReceiveProps ( nextProps ) {
204
+ if ( ! nextProps . autoplay && this . autoplayTimer ) {
201
205
clearTimeout ( this . autoplayTimer )
202
- if ( nextProps . index === this . props . index ) return
203
- this . setState (
204
- this . initState ( nextProps , this . props . index !== nextProps . index )
205
- )
206
+ this . setState ( this . initState ( nextProps ) )
207
+ } else if ( nextProps . autoplay ) {
208
+ this . autoplay ( nextProps . autoplay ) ;
209
+ this . loopJump ( ) ;
210
+ }
206
211
}
207
212
208
213
componentDidMount ( ) {
@@ -344,10 +349,11 @@ export default class extends Component {
344
349
/**
345
350
* Automatic rolling
346
351
*/
347
- autoplay = ( ) => {
348
- if (
349
- ! Array . isArray ( this . state . children ) ||
350
- ! this . props . autoplay ||
352
+
353
+ autoplay = ( autoplay ) => {
354
+ const toggleAutoplay = this . props . autoplay || autoplay ;
355
+ if ( ! Array . isArray ( this . props . children ) ||
356
+ ! toggleAutoplay ||
351
357
this . internals . isScrolling ||
352
358
this . state . autoplayEnd
353
359
)
0 commit comments