Fix overflow on Continuous Horizontal view (#793)

* Fix overflow on Continuous Horizontal view

* Calculate scrollbar size instead of rem

* Switch to ResizeObserver

* Observe Scrollbar Height on Reader

* Remove extraneous bracket

Silly mistake

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

---------

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>
This commit is contained in:
BrutuZ
2024-09-05 00:11:41 -03:00
committed by GitHub
parent 97b4befbb1
commit 9b4ddf34da
2 changed files with 19 additions and 6 deletions

View File

@@ -42,6 +42,7 @@ import { GET_CHAPTERS_READER } from '@/lib/graphql/queries/ChapterQuery.ts';
import { GET_MANGA_READER } from '@/lib/graphql/queries/MangaQuery.ts';
import { TMangaReader } from '@/lib/data/Mangas.ts';
import { CHAPTER_READER_FIELDS } from '@/lib/graphql/fragments/ChapterFragments.ts';
import { useResizeObserver } from '@/util/useResizeObserver';
type TChapter = GetChaptersReaderQuery['chapters']['nodes'][number];
@@ -487,6 +488,12 @@ export function Reader() {
openNextChapter(ChapterOffset.PREV);
}, [openNextChapter]);
const [scrollbarHeight, setScrollbarHeight] = useState(0);
useResizeObserver(
document.documentElement,
useCallback(() => setScrollbarHeight(window.innerHeight - document.documentElement.clientHeight), []),
);
if (isLoading) {
return (
<Box
@@ -553,7 +560,7 @@ export function Reader() {
alignItems: 'center',
justifyContent: 'center',
minWidth: `calc((100vw - (100vw - 100%)) - ${navBarWidth}px)`, // 100vw = width excluding scrollbar; 100% = width including scrollbar
minHeight: '100vh',
minHeight: `calc(100vh - ${scrollbarHeight}px)`,
marginLeft: `${navBarWidth}px`,
}}
>