fix broken scroll on mobile

This commit is contained in:
Hossein Mehrabi
2022-10-10 11:39:07 +03:30
parent dbf6dbb137
commit 31e8522167
3 changed files with 22 additions and 5 deletions
+1
View File
@@ -24,6 +24,7 @@
}
:root {
&,
body {
overflow-x: hidden !important;
}
+4 -3
View File
@@ -13,11 +13,12 @@
background: none;
}
:root {
}
@include utils.responsive('lg', 'down') {
.navbar {
background: var(--ifm-background-surface-color);
}
}
.overflow-hidden {
overflow: hidden !important;
}
+17 -2
View File
@@ -1,12 +1,27 @@
import React from 'react'
import { useNavbarMobileSidebar } from '@docusaurus/theme-common/internal'
import type { WrapperProps } from '@docusaurus/types'
import Navbar from '@theme-original/Navbar'
import type NavbarType from '@theme/Navbar'
import type { WrapperProps } from '@docusaurus/types'
import React, { useEffect } from 'react'
import './index.scss'
type Props = WrapperProps<typeof NavbarType>
export default function NavbarWrapper(props: Props): JSX.Element {
const mobileSidebar = useNavbarMobileSidebar()
useEffect(() => {
if (mobileSidebar.shown) {
document
.querySelector('#__docusaurus')
?.classList?.add?.('overflow-hidden')
} else {
document
.querySelector('#__docusaurus')
?.classList?.remove?.('overflow-hidden')
}
}, [mobileSidebar.shown])
return (
<>
<Navbar {...props} />