From 1d955257ddad21097308569f04973d832ffab9be Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Tue, 31 Dec 2024 02:32:52 +0100 Subject: [PATCH] Prevent page jump on scroll to page When an unloaded page got scrolled into view, the current page got incorrectly set to the next page once the page got loaded --- src/modules/reader/utils/ReaderPager.utils.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/modules/reader/utils/ReaderPager.utils.tsx b/src/modules/reader/utils/ReaderPager.utils.tsx index 37beff14..fb3c2b43 100644 --- a/src/modules/reader/utils/ReaderPager.utils.tsx +++ b/src/modules/reader/utils/ReaderPager.utils.tsx @@ -303,9 +303,7 @@ const getIsPageInViewportInfo = ( } => { const { top, bottom, left, right } = element.getBoundingClientRect(); - // for some reason using "scrollIntoView" to scroll a page into view does not always result in the page to be at top, - // left/right 0px and instead at something like -0.25px - const MIN_VISIBLE_PX = 1; + const MIN_VISIBLE_PX = 0; const isLeftInViewport = left >= MIN_VISIBLE_PX && left <= window.innerWidth; const isRightInViewport = right >= MIN_VISIBLE_PX && right <= window.innerWidth;