Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 0b23718

Browse files
committed
refactor(scrollbar): do not custom scrollbar on mobile
1 parent 7f7dfe6 commit 0b23718

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

components/Hooks/usePlatform.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const inialPlatform = {
1010
isIE: false,
1111
isEdge: false,
1212
isMacOS: false,
13+
isMobile: false,
1314
}
1415

1516
// see https://stackoverflow.com/questions/49328382/browser-detection-in-reactjs/49328524
@@ -44,6 +45,8 @@ const usePlatform = (/* { breakpoint } */) => {
4445
const isMacOS = Global.navigator.appVersion.indexOf('Mac') != -1
4546
/* eslint-enable */
4647

48+
const isMobile = Global.innerWidth <= 800 && window.innerHeight <= 600
49+
4750
setPlatform(
4851
R.merge(inialPlatform, {
4952
isFirefox,
@@ -52,6 +55,7 @@ const usePlatform = (/* { breakpoint } */) => {
5255
isEdge,
5356
isChrome,
5457
isMacOS,
58+
isMobile,
5559
})
5660
)
5761

containers/ThemeWrapper/GlobalStyle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ const GlobalStyle = createGlobalStyle`
139139
color: ${theme('searchHighlight.doramonFg')};
140140
}
141141
142-
${({ isMacOS }) =>
143-
isMacOS ||
142+
${({ showCustomScrollbar }) =>
143+
showCustomScrollbar ||
144144
css`
145145
::-webkit-scrollbar {
146146
background: transparent;

containers/ThemeWrapper/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ import AntUIOverWrite from './AntUIOverWrite'
1717
import GlobalStyle from './GlobalStyle'
1818

1919
const ThemeContainer = ({ children, theme: { themeData } }) => {
20-
const { isMacOS } = usePlatform()
21-
22-
console.log('isMacOS: ', isMacOS)
20+
const { isMacOS, isMobile } = usePlatform()
21+
const showCustomScrollbar = !isMacOS || !isMobile
2322

2423
return (
2524
<ThemeProvider theme={themeData}>
@@ -30,7 +29,7 @@ const ThemeContainer = ({ children, theme: { themeData } }) => {
3029
<div>{children}</div>
3130
<CodeSyxHighlight />
3231
<AntUIOverWrite />
33-
<GlobalStyle isMacOS={isMacOS} />
32+
<GlobalStyle showCustomScrollbar={showCustomScrollbar} />
3433
</React.Fragment>
3534
</ThemeProvider>
3635
)

0 commit comments

Comments
 (0)