Skip to content

Commit

Permalink
fix scrollToPage bug, for SegmentedView and SegmentedBarExample
Browse files Browse the repository at this point in the history
  • Loading branch information
rilyu committed May 9, 2017
1 parent f6544c1 commit ea8a57f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions components/SegmentedView/SegmentedView.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,13 @@ export default class SegmentedView extends Component {
if (index == this.state.activeIndex) return;
this.setState({activeIndex: index}, () => {
if (this.refs.carousel) {
this._ignoreCarouselChange = setTimeout(() => {
this._ignoreCarouselChange = null;
}, 300);
this.refs.carousel.scrollToPage(index);
this.refs.carousel.scrollToPage(index, false);
}
this.props.onChange && this.props.onChange(index);
});
}

onCarouselChange(index) {
if (this._ignoreCarouselChange) return;
this.setState({activeIndex: index}, () => {
this.props.onChange && this.props.onChange(index);
});
Expand Down
6 changes: 1 addition & 5 deletions example/views/SegmentedBarExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@ export default class SegmentedBarExample extends NavigationPage {
if (index != this.state.activeIndex) {
this.setState({activeIndex: index});
if (this.refs.carousel) {
this._ignoreCarouselChange = setTimeout(() => {
this._ignoreCarouselChange = null;
}, 300);
this.refs.carousel.scrollToPage(index);
this.refs.carousel.scrollToPage(index, false);
}
}
}

onCarouselChange(index) {
if (this._ignoreCarouselChange) return;
this.setState({activeIndex: index});
}

Expand Down

0 comments on commit ea8a57f

Please sign in to comment.