diff --git a/src/components/reader/pager/HorizontalPager.tsx b/src/components/reader/pager/HorizontalPager.tsx index 0eb9731e..79d60dca 100644 --- a/src/components/reader/pager/HorizontalPager.tsx +++ b/src/components/reader/pager/HorizontalPager.tsx @@ -114,6 +114,10 @@ export function HorizontalPager(props: IReaderProps) { } const resizeObserver = new ResizeObserver(() => { + if (!initialPageElement.offsetHeight) { + return; + } + initialPageElement.scrollIntoView({ inline: 'center' }); resizeObserver.disconnect(); }); diff --git a/src/components/reader/pager/VerticalPager.tsx b/src/components/reader/pager/VerticalPager.tsx index 6ee1155e..d363afc6 100644 --- a/src/components/reader/pager/VerticalPager.tsx +++ b/src/components/reader/pager/VerticalPager.tsx @@ -172,6 +172,10 @@ export function VerticalPager(props: IReaderProps) { } const resizeObserver = new ResizeObserver(() => { + if (!initialPageElement.offsetHeight) { + return; + } + initialPageElement.scrollIntoView(); resizeObserver.disconnect(); });