Fix preserving scroll position on infinite scroll previous chapter load (#913)

When scrolling to the previous chapter, which has not been preloaded, the scroll position got lost due to the resulting layout shift

* Update scroll preserve by tracking cursor

* Clean up interface

* Observe just the wrappers instead of individual images

* Switch to `IntersectionObserver` for tracking active element

* Clean up adding of observations

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:
Constantin Piber
2025-04-05 12:45:52 +02:00
committed by GitHub
parent b3860e4351
commit 4423dee14e
2 changed files with 72 additions and 57 deletions

View File

@@ -282,14 +282,9 @@ const BaseReaderViewer = forwardRef(
useReaderAutoScroll(isOverlayVisible, automaticScrolling);
useReaderPreserveScrollPosition(
scrollElementRef,
currentChapter?.id,
currentChapterIndex,
currentPageIndex,
chaptersToRender,
visibleChapters,
readingMode,
isContinuousReadingModeActive,
readingDirection,
readerNavBarWidth,
setPageToScrollToIndex,
pageScaleMode,