Skip to content

Commit c003604

Browse files
committed
[fix] ScrollView methods and horizontal layout
Horizontal ScrollView was not scrollable when combined with RefreshControl. Add a stub for the flashScrollIndicators method.
1 parent 4bc16fa commit c003604

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

packages/react-native-web/src/exports/ScrollView/ScrollViewBase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export default class ScrollViewBase extends Component<*> {
129129
onTouchMove={this._createPreventableScrollHandler(this.props.onTouchMove)}
130130
onWheel={this._createPreventableScrollHandler(this.props.onWheel)}
131131
ref={this._setViewRef}
132-
style={[style, !scrollEnabled && styles.scrollDisabled]}
132+
style={StyleSheet.compose(style, !scrollEnabled && styles.scrollDisabled)}
133133
/>
134134
);
135135
}

packages/react-native-web/src/exports/ScrollView/index.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ const ScrollView = createReactClass({
4444
return this.scrollResponderMixinGetInitialState();
4545
},
4646

47+
flashScrollIndicators() {
48+
this.scrollResponderFlashScrollIndicators();
49+
},
50+
4751
setNativeProps(props: Object) {
4852
if (this._scrollViewRef) {
4953
this._scrollViewRef.setNativeProps(props);
@@ -169,9 +173,11 @@ const ScrollView = createReactClass({
169173
/>
170174
);
171175

176+
const baseStyle = horizontal ? styles.baseHorizontal : styles.baseVertical;
177+
172178
const props = {
173179
...other,
174-
style: [styles.base, horizontal && styles.baseHorizontal, this.props.style],
180+
style: [baseStyle, this.props.style],
175181
onTouchStart: this.scrollResponderHandleTouchStart,
176182
onTouchMove: this.scrollResponderHandleTouchMove,
177183
onTouchEnd: this.scrollResponderHandleTouchEnd,
@@ -198,7 +204,7 @@ const ScrollView = createReactClass({
198204
return React.cloneElement(
199205
refreshControl,
200206
{ style: props.style },
201-
<ScrollViewClass {...props} ref={this._setScrollViewRef} style={styles.base}>
207+
<ScrollViewClass {...props} ref={this._setScrollViewRef} style={baseStyle}>
202208
{contentContainer}
203209
</ScrollViewClass>
204210
);
@@ -245,21 +251,32 @@ const ScrollView = createReactClass({
245251
}
246252
});
247253

254+
const commonStyle = {
255+
flexGrow: 1,
256+
flexShrink: 1,
257+
overscrollBehavior: 'contain',
258+
// Enable hardware compositing in modern browsers.
259+
// Creates a new layer with its own backing surface that can significantly
260+
// improve scroll performance.
261+
transform: [{ translateZ: 0 }],
262+
// iOS native scrolling
263+
WebkitOverflowScrolling: 'touch'
264+
};
265+
248266
const styles = StyleSheet.create({
249-
base: {
250-
flex: 1,
267+
baseVertical: {
268+
...commonStyle,
269+
flexDirection: 'column',
251270
overflowX: 'hidden',
252271
overflowY: 'auto',
253-
WebkitOverflowScrolling: 'touch',
254-
// Enable hardware compositing in modern browsers.
255-
// Creates a new layer with its own backing surface that can significantly
256-
// improve scroll performance.
257-
transform: [{ translateZ: 0 }]
272+
touchAction: 'pan-y'
258273
},
259274
baseHorizontal: {
275+
...commonStyle,
260276
flexDirection: 'row',
261277
overflowX: 'auto',
262-
overflowY: 'hidden'
278+
overflowY: 'hidden',
279+
touchAction: 'pan-x'
263280
},
264281
contentContainerHorizontal: {
265282
flexDirection: 'row'

packages/react-native-web/src/modules/ScrollResponder/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ const ScrollResponderMixin = {
411411
}
412412
},
413413

414+
/**
415+
* Displays the scroll indicators momentarily.
416+
*/
417+
scrollResponderFlashScrollIndicators: function() {},
418+
414419
/**
415420
* This method should be used as the callback to onFocus in a TextInputs'
416421
* parent view. Note that any module using this mixin needs to return

0 commit comments

Comments
 (0)