Skip to content

Commit 64c5b1f

Browse files
author
Simar
committed
added scrollWithoutAnimation prop
default is false, if true, there is no scrolling animation when tapping on a tabbar icon
1 parent b1f78bb commit 64c5b1f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const ScrollableTabView = React.createClass({
3434
renderTabBar: PropTypes.any,
3535
style: View.propTypes.style,
3636
contentProps: PropTypes.object,
37+
scrollWithoutAnimation: PropTypes.bool
3738
},
3839

3940
getDefaultProps() {
@@ -44,6 +45,7 @@ const ScrollableTabView = React.createClass({
4445
onChangeTab: () => {},
4546
onScroll: () => {},
4647
contentProps: {},
48+
scrollWithoutAnimation: false
4749
};
4850
},
4951

@@ -67,11 +69,16 @@ const ScrollableTabView = React.createClass({
6769
if (Platform.OS === 'ios') {
6870
const offset = pageNumber * this.state.containerWidth;
6971
if (this.scrollView) {
70-
this.scrollView.scrollTo({x: offset, y: 0, });
72+
this.scrollView.scrollTo({x: offset, y: 0, animated: !this.props.scrollWithoutAnimation});
7173
}
7274
} else {
7375
if (this.scrollView) {
74-
this.scrollView.setPage(pageNumber);
76+
if(this.props.scrollWithoutAnimation) {
77+
this.scrollView.setPageWithoutAnimation(pageNumber);
78+
}
79+
else{
80+
this.scrollView.setPage(pageNumber);
81+
}
7582
}
7683
}
7784

0 commit comments

Comments
 (0)