Skip to content

Commit

Permalink
Fix: Desktop Scrollbar appears on some mobile browsers (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
duogenesis authored Dec 29, 2024
1 parent 19e4abd commit 417ed3f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
4 changes: 3 additions & 1 deletion App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import { DonationNagModal } from './components/donation-nag-modal';
import { createWebNavigator } from './components/navigation/web-navigator';
import { isMobile } from './util/util';
import { Logo16 } from './components/logo';
import './global.css';
import { useScrollbarStyle } from './components/navigation/scroll-bar-hooks';


// TODO: Onboarding works
Expand Down Expand Up @@ -464,6 +464,8 @@ const App = () => {
})();
}, [isLoading]);

useScrollbarStyle();

if (serverStatus !== "ok") {
return <UtilityScreen serverStatus={serverStatus}/>
}
Expand Down
36 changes: 36 additions & 0 deletions components/navigation/scroll-bar-hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,42 @@ const useScrollbar = (controller: string) => {
}).current;
};

const useScrollbarStyle = () => {
const desktopScrollbarCSS = `
::-webkit-scrollbar {
width: 14px;
}
::-webkit-scrollbar-track {
background: #ddd;
}
::-webkit-scrollbar-thumb {
background-color: #70f;
border-radius: 99px;
}
@-moz-document url-prefix() {
* {
scrollbar-color: #70f #ddd;
}
*::-moz-scrollbar-thumb {
border-radius: 99px;
}
}
`;

useEffect(() => {
if (!isMobile()) {
const styleEl = document.createElement('style');
styleEl.textContent = desktopScrollbarCSS;
document.head.appendChild(styleEl);
}
}, []);
};

export {
useScrollbar,
useScrollbarStyle,
};
2 changes: 1 addition & 1 deletion components/navigation/scroll-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type ScrollViewData = {
controller: string | null;

// A callback to call when the Scrollbar's thumb is dragged
onThumbDrag?: (offset: number) => void;
onThumbDrag?: null | ((offset: number) => void);

// The height of the controlling Scrollview's content
contentHeight?: number;
Expand Down
25 changes: 0 additions & 25 deletions global.css

This file was deleted.

0 comments on commit 417ed3f

Please sign in to comment.