Skip to content

Commit 28abcb3

Browse files
committed
fix goToPage
1 parent 92f45dc commit 28abcb3

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,12 @@ const ScrollableTabView = React.createClass({
6767
},
6868

6969
componentDidMount() {
70-
const scrollFn = () => {
71-
if (this.scrollView && Platform.OS === 'android') {
72-
const x = this.props.initialPage * this.state.containerWidth;
73-
this.scrollView.scrollTo({ x, animated: false });
74-
}
75-
};
7670
this.setTimeout(() => {
77-
InteractionManager.runAfterInteractions(scrollFn);
71+
InteractionManager.runAfterInteractions(() => {
72+
if (Platform.OS === 'android') {
73+
this.goToPage(this.props.initialPage, false);
74+
}
75+
});
7876
}, 0);
7977

8078
this.state.scrollX.addListener(({ value, }) => {
@@ -94,10 +92,10 @@ const ScrollableTabView = React.createClass({
9492
}
9593
},
9694

97-
goToPage(pageNumber) {
95+
goToPage(pageNumber, animated = !this.props.scrollWithoutAnimation) {
9896
const offset = pageNumber * this.state.containerWidth;
99-
if (this.scrollView) {
100-
this.scrollView.scrollTo({x: offset, y: 0, animated: !this.props.scrollWithoutAnimation, });
97+
if (this.scrollView && this.scrollView._component && this.scrollView._component.scrollTo) {
98+
this.scrollView._component.scrollTo({x: offset, y: 0, animated, });
10199
}
102100

103101
const currentPage = this.state.currentPage;

0 commit comments

Comments
 (0)