Skip to content

Commit

Permalink
🐛 Auto scroll X behavior outside of editor
Browse files Browse the repository at this point in the history
Closes #440
  • Loading branch information
baptisteArno committed Apr 17, 2023
1 parent f8a76f9 commit 928afd5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions apps/builder/src/assets/styles/custom.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
html,
body {
.disable-scroll-x-behavior {
overscroll-behavior-x: none;
}

Expand Down
10 changes: 7 additions & 3 deletions apps/builder/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 928afd5

Please sign in to comment.