@@ -78,11 +78,26 @@ class TabController extends Component {
78
78
this . setState ( { itemStates, ignoredItems} ) ;
79
79
} ;
80
80
81
+ getCarouselPageChangeCode ( ) {
82
+ const { asCarousel} = this . props ;
83
+ const { itemStates} = this . state ;
84
+
85
+ if ( asCarousel ) {
86
+ // Rounding on Android, cause it cause issues when comparing values
87
+ const screenWidth = Constants . isAndroid ? Math . round ( Constants . screenWidth ) : Constants . screenWidth ;
88
+
89
+ return _ . times ( itemStates . length , index => {
90
+ return cond ( eq ( Constants . isAndroid ? round ( this . _carouselOffset ) : this . _carouselOffset , index * screenWidth ) , [
91
+ set ( this . _currentPage , index )
92
+ ] ) ;
93
+ } ) ;
94
+ }
95
+
96
+ return [ ] ;
97
+ }
98
+
81
99
render ( ) {
82
100
const { itemStates, ignoredItems} = this . state ;
83
-
84
- // Rounding on Android, cause it cause issues when comparing values
85
- const screenWidth = Constants . isAndroid ? Math . round ( Constants . screenWidth ) : Constants . screenWidth ;
86
101
87
102
return (
88
103
< TabBarContext . Provider value = { this . getProviderContextValue ( ) } >
@@ -92,11 +107,7 @@ class TabController extends Component {
92
107
{ ( ) =>
93
108
block ( [
94
109
// Carousel Page change
95
- ..._ . times ( itemStates . length , index => {
96
- return cond ( eq ( Constants . isAndroid ? round ( this . _carouselOffset ) : this . _carouselOffset ,
97
- index * screenWidth ) ,
98
- [ set ( this . _currentPage , index ) ] ) ;
99
- } ) ,
110
+ ...this . getCarouselPageChangeCode ( ) ,
100
111
// TabBar Page change
101
112
..._ . map ( itemStates , ( state , index ) => {
102
113
return [
0 commit comments