🐛 Auto scroll X behavior outside of editor

Closes #440
This commit is contained in:
Baptiste Arnaud
2023-04-17 15:41:48 +02:00
parent f8a76f98b9
commit 928afd5a6c
2 changed files with 8 additions and 5 deletions

View File

@@ -1,5 +1,4 @@
html,
body {
.disable-scroll-x-behavior {
overscroll-behavior-x: none;
}

View File

@@ -26,9 +26,13 @@ const App = ({ Component, pageProps }: AppProps) => {
const { query, pathname } = useRouter()
useEffect(() => {
pathname.endsWith('/edit')
? (document.body.style.overflow = 'hidden')
: (document.body.style.overflow = 'auto')
if (pathname.endsWith('/edit')) {
document.body.style.overflow = 'hidden'
document.body.classList.add('disable-scroll-x-behavior')
} else {
document.body.style.overflow = 'auto'
document.body.classList.remove('disable-scroll-x-behavior')
}
}, [pathname])
useEffect(() => {