Skip to content

Commit e22f0be

Browse files
committed
[fix] ScrollView disabling of scroll
Make sure 'scrollEnabled={false}' works on desktop browsers and no longer relies on using 'e.preventDefault()'. Fix #1491
1 parent f16c2c4 commit e22f0be

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

packages/docs/src/components/ScrollView/examples/Horizontal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export default function Horizontal() {
2727
}}
2828
/>
2929
<Button
30-
label="Scroll to 200px"
30+
label="Scroll to 50px"
3131
onPress={() => {
32-
scrollRef.current.scrollTo({ x: 200 });
32+
scrollRef.current.scrollTo({ x: 50 });
3333
}}
3434
/>
3535
<Button

packages/docs/src/components/ScrollView/examples/Vertical.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export default function Vertical() {
2323
}}
2424
/>
2525
<Button
26-
label="Scroll to 200px"
26+
label="Scroll to 50px"
2727
onPress={() => {
28-
scrollRef.current.scrollTo({ y: 200 });
28+
scrollRef.current.scrollTo({ y: 50 });
2929
}}
3030
/>
3131
<Button

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ export default class ScrollViewBase extends React.Component<Props> {
125125
if (handler) {
126126
handler(e);
127127
}
128-
} else {
129-
// To disable scrolling in all browsers except Chrome
130-
e.preventDefault();
131128
}
132129
};
133130
};
@@ -185,6 +182,8 @@ export default class ScrollViewBase extends React.Component<Props> {
185182
// https://developers.google.com/web/updates/2017/01/scrolling-intervention
186183
const styles = StyleSheet.create({
187184
scrollDisabled: {
185+
overflowX: 'hidden',
186+
overflowY: 'hidden',
188187
touchAction: 'none'
189188
},
190189
hideScrollbar: {

0 commit comments

Comments
 (0)