From ea8a57f19357bb1a4ce6f1ce1c1893c971cb6f28 Mon Sep 17 00:00:00 2001 From: Liangyu Date: Tue, 9 May 2017 15:43:31 +0800 Subject: [PATCH] fix scrollToPage bug, for SegmentedView and SegmentedBarExample --- components/SegmentedView/SegmentedView.js | 6 +----- example/views/SegmentedBarExample.js | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/components/SegmentedView/SegmentedView.js b/components/SegmentedView/SegmentedView.js index 8c80f35..e4f6860 100644 --- a/components/SegmentedView/SegmentedView.js +++ b/components/SegmentedView/SegmentedView.js @@ -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); }); diff --git a/example/views/SegmentedBarExample.js b/example/views/SegmentedBarExample.js index c41d9f5..ce3a426 100644 --- a/example/views/SegmentedBarExample.js +++ b/example/views/SegmentedBarExample.js @@ -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}); }