mirror of
https://github.com/updownupdown/tao
synced 2024-11-22 00:06:33 +00:00
Fix body scrolling
This commit is contained in:
parent
b9d4ec698e
commit
8fe6cde592
17
src/App.tsx
17
src/App.tsx
@ -49,27 +49,26 @@ function App() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleBodyScroll() {
|
||||
if (showChapterMenu || showTranslationMenu || showMainMenu) {
|
||||
document.body.style.overflow = "unset";
|
||||
} else {
|
||||
const menuOpen = showChapterMenu || showTranslationMenu || showMainMenu;
|
||||
|
||||
useEffect(() => {
|
||||
if (menuOpen) {
|
||||
document.body.style.overflow = "hidden";
|
||||
} else {
|
||||
document.body.style.overflow = "unset";
|
||||
}
|
||||
}
|
||||
}, [showChapterMenu, showTranslationMenu, showMainMenu]);
|
||||
|
||||
function showChapters() {
|
||||
setShowChapterMenu(!showChapterMenu);
|
||||
handleBodyScroll();
|
||||
}
|
||||
|
||||
function showTranslations() {
|
||||
setShowTranslationMenu(!showTranslationMenu);
|
||||
handleBodyScroll();
|
||||
}
|
||||
|
||||
function showMain() {
|
||||
setShowMainMenu(!showMainMenu);
|
||||
handleBodyScroll();
|
||||
}
|
||||
|
||||
function selectThemeColor(newTheme: string) {
|
||||
@ -108,7 +107,7 @@ function App() {
|
||||
|
||||
return (
|
||||
<div className={`main theme--${themeColor} theme--${themeFont}`}>
|
||||
{(showChapterMenu || showTranslationMenu || showMainMenu) && (
|
||||
{menuOpen && (
|
||||
<div
|
||||
className="overlay"
|
||||
onClick={() => {
|
||||
|
Loading…
Reference in New Issue
Block a user