Skip to content

Commit e3ca130

Browse files
committed
Merge pull request ptomasroos#91 from obsidian-btc/master
Interactions are improved
2 parents 40e8115 + 74121e1 commit e3ca130

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

index.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ var ScrollableTabView = React.createClass({
3737
};
3838
},
3939

40+
componentWillReceiveProps(props) {
41+
if (props.initialPage !== this.state.currentPage) {
42+
this.goToPage(props.initialPage);
43+
}
44+
},
45+
4046
goToPage(pageNumber) {
4147
this.props.onChangeTab && this.props.onChangeTab({
4248
i: pageNumber, ref: this.props.children[pageNumber]
@@ -115,7 +121,11 @@ var ScrollableTabView = React.createClass({
115121
if (typeof currentPage === 'object') {
116122
currentPage = currentPage.nativeEvent.position;
117123
}
118-
this.setState({currentPage});
124+
this.setState({currentPage}, function() {
125+
onChangeTab && onChangeTab({
126+
i: currentPage
127+
});
128+
});
119129
},
120130

121131
_updateScrollValue(value) {

0 commit comments

Comments
 (0)