|
9 | 9 | View,
|
10 | 10 | Animated,
|
11 | 11 | ScrollView,
|
12 |
| - Platform, |
13 | 12 | StyleSheet,
|
14 |
| - ViewPagerAndroid, |
15 | 13 | InteractionManager,
|
16 | 14 | } = ReactNative;
|
17 | 15 | const TimerMixin = require('react-timer-mixin');
|
@@ -76,19 +74,9 @@ const ScrollableTabView = React.createClass({
|
76 | 74 | },
|
77 | 75 |
|
78 | 76 | goToPage(pageNumber) {
|
79 |
| - if (Platform.OS === 'ios') { |
80 |
| - const offset = pageNumber * this.state.containerWidth; |
81 |
| - if (this.scrollView) { |
82 |
| - this.scrollView.scrollTo({x: offset, y: 0, animated: !this.props.scrollWithoutAnimation, }); |
83 |
| - } |
84 |
| - } else { |
85 |
| - if (this.scrollView) { |
86 |
| - if (this.props.scrollWithoutAnimation) { |
87 |
| - this.scrollView.setPageWithoutAnimation(pageNumber); |
88 |
| - } else { |
89 |
| - this.scrollView.setPage(pageNumber); |
90 |
| - } |
91 |
| - } |
| 77 | + const offset = pageNumber * this.state.containerWidth; |
| 78 | + if (this.scrollView) { |
| 79 | + this.scrollView.scrollTo({x: offset, y: 0, animated: !this.props.scrollWithoutAnimation, }); |
92 | 80 | }
|
93 | 81 |
|
94 | 82 | const currentPage = this.state.currentPage;
|
@@ -140,50 +128,30 @@ const ScrollableTabView = React.createClass({
|
140 | 128 | },
|
141 | 129 |
|
142 | 130 | renderScrollableContent() {
|
143 |
| - if (Platform.OS === 'ios') { |
144 |
| - const scenes = this._composeScenes(); |
145 |
| - return <ScrollView |
146 |
| - horizontal |
147 |
| - pagingEnabled |
148 |
| - automaticallyAdjustContentInsets={false} |
149 |
| - contentOffset={{ x: this.props.initialPage * this.state.containerWidth, }} |
150 |
| - ref={(scrollView) => { this.scrollView = scrollView; }} |
151 |
| - onScroll={(e) => { |
152 |
| - const offsetX = e.nativeEvent.contentOffset.x; |
153 |
| - this._updateScrollValue(offsetX / this.state.containerWidth); |
154 |
| - }} |
155 |
| - onMomentumScrollBegin={this._onMomentumScrollBeginAndEnd} |
156 |
| - onMomentumScrollEnd={this._onMomentumScrollBeginAndEnd} |
157 |
| - scrollEventThrottle={16} |
158 |
| - scrollsToTop={false} |
159 |
| - showsHorizontalScrollIndicator={false} |
160 |
| - scrollEnabled={!this.props.locked} |
161 |
| - directionalLockEnabled |
162 |
| - alwaysBounceVertical={false} |
163 |
| - keyboardDismissMode="on-drag" |
164 |
| - {...this.props.contentProps} |
| 131 | + const scenes = this._composeScenes(); |
| 132 | + return <ScrollView |
| 133 | + horizontal |
| 134 | + pagingEnabled |
| 135 | + automaticallyAdjustContentInsets={false} |
| 136 | + contentOffset={{ x: this.props.initialPage * this.state.containerWidth, }} |
| 137 | + ref={(scrollView) => { this.scrollView = scrollView; }} |
| 138 | + onScroll={(e) => { |
| 139 | + const offsetX = e.nativeEvent.contentOffset.x; |
| 140 | + this._updateScrollValue(offsetX / this.state.containerWidth); |
| 141 | + }} |
| 142 | + onMomentumScrollBegin={this._onMomentumScrollBeginAndEnd} |
| 143 | + onMomentumScrollEnd={this._onMomentumScrollBeginAndEnd} |
| 144 | + scrollEventThrottle={16} |
| 145 | + scrollsToTop={false} |
| 146 | + showsHorizontalScrollIndicator={false} |
| 147 | + scrollEnabled={!this.props.locked} |
| 148 | + directionalLockEnabled |
| 149 | + alwaysBounceVertical={false} |
| 150 | + keyboardDismissMode="on-drag" |
| 151 | + {...this.props.contentProps} |
165 | 152 | >
|
166 |
| - {scenes} |
167 |
| - </ScrollView>; |
168 |
| - } else { |
169 |
| - const scenes = this._composeScenes(); |
170 |
| - return <ViewPagerAndroid |
171 |
| - key={this._children().length} |
172 |
| - style={styles.scrollableContentAndroid} |
173 |
| - initialPage={this.props.initialPage} |
174 |
| - onPageSelected={this._updateSelectedPage} |
175 |
| - keyboardDismissMode="on-drag" |
176 |
| - scrollEnabled={!this.props.locked} |
177 |
| - onPageScroll={(e) => { |
178 |
| - const { offset, position, } = e.nativeEvent; |
179 |
| - this._updateScrollValue(position + offset); |
180 |
| - }} |
181 |
| - ref={(scrollView) => { this.scrollView = scrollView; }} |
182 |
| - {...this.props.contentProps} |
183 |
| - > |
184 |
| - {scenes} |
185 |
| - </ViewPagerAndroid>; |
186 |
| - } |
| 153 | + {scenes} |
| 154 | + </ScrollView>; |
187 | 155 | },
|
188 | 156 |
|
189 | 157 | _composeScenes() {
|
|
0 commit comments