Skip to content

Commit 49ef3fb

Browse files
author
soliury
committed
nav can press
1 parent 3819bda commit 49ef3fb

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/components/ScrollableTabs.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,22 @@ class ScrollableTabs extends Component {
127127
}
128128

129129
return (
130-
<View ref={ view => this._navs[index]=view} key={index}
131-
style={[styles.navItem, { width: this.props.tabNavItemWidth }, activeStyle]}>
132-
<TouchableOpacity>
130+
<TouchableOpacity key={index} onPress={()=>{
131+
this.scrollView && this.scrollView.scrollTo({
132+
x: width * index,
133+
y: 0,
134+
animated: true
135+
});
136+
}}>
137+
<View ref={ view => this._navs[index]=view} key={index}
138+
style={[styles.navItem, { width: this.props.tabNavItemWidth }, activeStyle]}>
139+
133140
<Text style={styles.itemText}>
134141
{ item }
135142
</Text>
136-
</TouchableOpacity>
137-
</View>
143+
144+
</View>
145+
</TouchableOpacity>
138146
)
139147
});
140148
}
@@ -254,7 +262,8 @@ const styles = StyleSheet.create({
254262
},
255263
itemText: {
256264
textAlign: 'center',
257-
color: 'rgba(255,255,255,0.7)'
265+
color: 'rgba(255,255,255,0.7)',
266+
flex: 1
258267
},
259268
page: {
260269
width

0 commit comments

Comments
 (0)