@@ -129,6 +129,7 @@ export default class extends Component {
129129 automaticallyAdjustContentInsets : PropTypes . bool ,
130130 showsPagination : PropTypes . bool ,
131131 showsButtons : PropTypes . bool ,
132+ disableNextButton : PropTypes . bool ,
132133 loadMinimal : PropTypes . bool ,
133134 loadMinimalSize : PropTypes . number ,
134135 loadMinimalLoader : PropTypes . element ,
@@ -138,8 +139,8 @@ export default class extends Component {
138139 autoplayDirection : PropTypes . bool ,
139140 index : PropTypes . number ,
140141 renderPagination : PropTypes . func ,
141- dotStyle : PropTypes . object ,
142- activeDotStyle : PropTypes . object ,
142+ dotStyle : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . number ] ) ,
143+ activeDotStyle : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . number ] ) ,
143144 dotColor : PropTypes . string ,
144145 activeDotColor : PropTypes . string ,
145146 /**
@@ -164,6 +165,7 @@ export default class extends Component {
164165 automaticallyAdjustContentInsets : false ,
165166 showsPagination : true ,
166167 showsButtons : false ,
168+ disableNextButton : false ,
167169 loop : true ,
168170 loadMinimal : false ,
169171 loadMinimalSize : 1 ,
@@ -212,7 +214,8 @@ export default class extends Component {
212214
213215 const initState = {
214216 autoplayEnd : false ,
215- loopJump : false
217+ loopJump : false ,
218+ offset : { }
216219 }
217220
218221 initState . total = props . children ? props . children . length || 1 : 0
@@ -226,6 +229,7 @@ export default class extends Component {
226229
227230 // Default: horizontal
228231 initState . dir = props . horizontal === false ? 'y' : 'x'
232+
229233 if ( props . width ) {
230234 initState . width = props . width
231235 } else if ( this . state && this . state . width ) {
@@ -242,6 +246,11 @@ export default class extends Component {
242246 initState . height = height ;
243247 }
244248
249+ initState . offset [ initState . dir ] = initState . dir === 'y'
250+ ? height * props . index
251+ : width * props . index
252+
253+
245254 this . internals = {
246255 ...this . internals ,
247256 isScrolling : false
@@ -280,7 +289,7 @@ export default class extends Component {
280289 loopJump = ( ) => {
281290 if ( ! this . state . loopJump ) return
282291 const i = this . state . index + ( this . props . loop ? 1 : 0 )
283- const scrollView = this . refs . scrollView
292+ const scrollView = this . scrollView
284293 this . loopJumpTimer = setTimeout ( ( ) => scrollView . setPageWithoutAnimation &&
285294 scrollView . setPageWithoutAnimation ( i ) , 50 )
286295 }
@@ -436,10 +445,10 @@ export default class extends Component {
436445 if ( state . dir === 'x' ) x = diff * state . width
437446 if ( state . dir === 'y' ) y = diff * state . height
438447
439- if ( Platform . OS === 'android ') {
440- this . refs . scrollView && this . refs . scrollView [ animated ? 'setPage' : 'setPageWithoutAnimation' ] ( diff )
448+ if ( Platform . OS !== 'ios ') {
449+ this . scrollView && this . scrollView [ animated ? 'setPage' : 'setPageWithoutAnimation' ] ( diff )
441450 } else {
442- this . refs . scrollView && this . refs . scrollView . scrollTo ( { x, y, animated } )
451+ this . scrollView && this . scrollView . scrollTo ( { x, y, animated } )
443452 }
444453
445454 // update scroll state
@@ -449,7 +458,7 @@ export default class extends Component {
449458 } )
450459
451460 // trigger onScrollEnd manually in android
452- if ( ! animated || Platform . OS === 'android ') {
461+ if ( ! animated || Platform . OS !== 'ios ') {
453462 setImmediate ( ( ) => {
454463 this . onScrollEnd ( {
455464 nativeEvent : {
@@ -551,7 +560,10 @@ export default class extends Component {
551560 }
552561
553562 return (
554- < TouchableOpacity onPress = { ( ) => button !== null && this . scrollBy ( 1 ) } >
563+ < TouchableOpacity
564+ onPress = { ( ) => button !== null && this . scrollBy ( 1 ) }
565+ disabled = { this . props . disableNextButton }
566+ >
555567 < View >
556568 { button }
557569 </ View >
@@ -587,10 +599,14 @@ export default class extends Component {
587599 )
588600 }
589601
602+ refScrollView = view => {
603+ this . scrollView = view ;
604+ }
605+
590606 renderScrollView = pages => {
591607 if ( Platform . OS === 'ios' ) {
592608 return (
593- < ScrollView ref = 'scrollView'
609+ < ScrollView ref = { this . refScrollView }
594610 { ...this . props }
595611 { ...this . scrollViewPropOverrides ( ) }
596612 contentContainerStyle = { [ styles . wrapperIOS , this . props . style ] }
@@ -604,7 +620,7 @@ export default class extends Component {
604620 )
605621 }
606622 return (
607- < ViewPagerAndroid ref = 'scrollView'
623+ < ViewPagerAndroid ref = { this . refScrollView }
608624 { ...this . props }
609625 initialPage = { this . props . loop ? this . state . index + 1 : this . state . index }
610626 onPageSelected = { this . onScrollEnd }
0 commit comments