@@ -269,7 +269,7 @@ export default class extends Component {
269269 loopJump = ( ) => {
270270 if ( ! this . state . loopJump ) return
271271 const i = this . state . index + ( this . props . loop ? 1 : 0 )
272- const scrollView = this . refs . scrollView
272+ const scrollView = this . scrollView
273273 this . loopJumpTimer = setTimeout ( ( ) => scrollView . setPageWithoutAnimation &&
274274 scrollView . setPageWithoutAnimation ( i ) , 50 )
275275 }
@@ -425,10 +425,10 @@ export default class extends Component {
425425 if ( state . dir === 'x' ) x = diff * state . width
426426 if ( state . dir === 'y' ) y = diff * state . height
427427
428- if ( Platform . OS === 'android ') {
429- this . refs . scrollView && this . refs . scrollView [ animated ? 'setPage' : 'setPageWithoutAnimation' ] ( diff )
428+ if ( Platform . OS !== 'ios ') {
429+ this . scrollView && this . scrollView [ animated ? 'setPage' : 'setPageWithoutAnimation' ] ( diff )
430430 } else {
431- this . refs . scrollView && this . refs . scrollView . scrollTo ( { x, y, animated } )
431+ this . scrollView && this . scrollView . scrollTo ( { x, y, animated } )
432432 }
433433
434434 // update scroll state
@@ -438,7 +438,7 @@ export default class extends Component {
438438 } )
439439
440440 // trigger onScrollEnd manually in android
441- if ( ! animated || Platform . OS === 'android ') {
441+ if ( ! animated || Platform . OS !== 'ios ') {
442442 setImmediate ( ( ) => {
443443 this . onScrollEnd ( {
444444 nativeEvent : {
@@ -579,10 +579,14 @@ export default class extends Component {
579579 )
580580 }
581581
582+ refScrollView = view => {
583+ this . scrollView = view ;
584+ }
585+
582586 renderScrollView = pages => {
583587 if ( Platform . OS === 'ios' ) {
584588 return (
585- < ScrollView ref = 'scrollView'
589+ < ScrollView ref = { this . refScrollView }
586590 { ...this . props }
587591 { ...this . scrollViewPropOverrides ( ) }
588592 contentContainerStyle = { [ styles . wrapperIOS , this . props . style ] }
@@ -595,7 +599,7 @@ export default class extends Component {
595599 )
596600 }
597601 return (
598- < ViewPagerAndroid ref = 'scrollView'
602+ < ViewPagerAndroid ref = { this . refScrollView }
599603 { ...this . props }
600604 initialPage = { this . props . loop ? this . state . index + 1 : this . state . index }
601605 onPageSelected = { this . onScrollEnd }
0 commit comments