@@ -98,6 +98,7 @@ class TabBar extends PureComponent {
98
98
} ;
99
99
100
100
this . state = {
101
+ scrollEnabled : false ,
101
102
itemsWidths : undefined ,
102
103
} ;
103
104
@@ -119,6 +120,12 @@ class TabBar extends PureComponent {
119
120
}
120
121
} ;
121
122
123
+ onContentSizeChange = width => {
124
+ if ( width > Constants . screenWidth ) {
125
+ this . setState ( { scrollEnabled : true } ) ;
126
+ }
127
+ } ;
128
+
122
129
runTiming ( targetValue , prevValue , duration ) {
123
130
const clock = new Clock ( ) ;
124
131
const state = {
@@ -149,19 +156,10 @@ class TabBar extends PureComponent {
149
156
}
150
157
151
158
renderSelectedIndicator ( ) {
152
- // return null;
153
159
const { itemsWidths} = this . state ;
154
160
const { indicatorStyle} = this . props ;
155
161
if ( itemsWidths ) {
156
- // const transitionStyle = {
157
- // width: this.runTiming(this._indicatorWidth, this._prevIndicatorWidth, 300),
158
- // left: this.runTiming(this._offset, this._prevOffset, 400),
159
- // };
160
- return (
161
- < Reanimated . View
162
- style = { [ styles . selectedIndicator , indicatorStyle /* , transitionStyle */ , this . _indicatorTransitionStyle ] }
163
- />
164
- ) ;
162
+ return < Reanimated . View style = { [ styles . selectedIndicator , indicatorStyle , this . _indicatorTransitionStyle ] } /> ;
165
163
}
166
164
}
167
165
@@ -177,7 +175,6 @@ class TabBar extends PureComponent {
177
175
activeBackgroundColor,
178
176
} = this . props ;
179
177
if ( ! _ . isEmpty ( itemStates ) ) {
180
-
181
178
if ( this . tabBarItems ) {
182
179
return this . tabBarItems ;
183
180
}
@@ -205,7 +202,7 @@ class TabBar extends PureComponent {
205
202
render ( ) {
206
203
const { currentPage} = this . context ;
207
204
const { containerWidth, height, enableShadow} = this . props ;
208
- const { itemsWidths, itemsOffsets} = this . state ;
205
+ const { itemsWidths, itemsOffsets, scrollEnabled } = this . state ;
209
206
return (
210
207
< View style = { enableShadow && styles . containerShadow } >
211
208
< ScrollView
@@ -214,6 +211,8 @@ class TabBar extends PureComponent {
214
211
showsHorizontalScrollIndicator = { false }
215
212
style = { styles . tabBarScroll }
216
213
contentContainerStyle = { styles . tabBarScrollContent }
214
+ scrollEnabled = { scrollEnabled }
215
+ onContentSizeChange = { this . onContentSizeChange }
217
216
>
218
217
< View style = { [ styles . tabBar , height && { height} ] } > { this . renderTabBarItems ( ) } </ View >
219
218
{ this . renderSelectedIndicator ( ) }
0 commit comments