mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-02 18:41:17 +00:00
[fix] ScrollView disabling of scroll
Make sure 'scrollEnabled={false}' works on desktop browsers and no longer
relies on using 'e.preventDefault()'.
Fix #1491
This commit is contained in:
@@ -27,9 +27,9 @@ export default function Horizontal() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
label="Scroll to 200px"
|
label="Scroll to 50px"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
scrollRef.current.scrollTo({ x: 200 });
|
scrollRef.current.scrollTo({ x: 50 });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ export default function Vertical() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
label="Scroll to 200px"
|
label="Scroll to 50px"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
scrollRef.current.scrollTo({ y: 200 });
|
scrollRef.current.scrollTo({ y: 50 });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -125,9 +125,6 @@ export default class ScrollViewBase extends React.Component<Props> {
|
|||||||
if (handler) {
|
if (handler) {
|
||||||
handler(e);
|
handler(e);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// To disable scrolling in all browsers except Chrome
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -185,6 +182,8 @@ export default class ScrollViewBase extends React.Component<Props> {
|
|||||||
// https://developers.google.com/web/updates/2017/01/scrolling-intervention
|
// https://developers.google.com/web/updates/2017/01/scrolling-intervention
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
scrollDisabled: {
|
scrollDisabled: {
|
||||||
|
overflowX: 'hidden',
|
||||||
|
overflowY: 'hidden',
|
||||||
touchAction: 'none'
|
touchAction: 'none'
|
||||||
},
|
},
|
||||||
hideScrollbar: {
|
hideScrollbar: {
|
||||||
|
|||||||
Reference in New Issue
Block a user