Simplify reader visible page detection

This commit is contained in:
schroda
2025-11-17 02:11:05 +01:00
parent 36477d1c95
commit 48b57c4a74
2 changed files with 21 additions and 21 deletions

View File

@@ -494,22 +494,8 @@ export class ReaderControls {
type: PageInViewportType,
readingDirection: ReadingDirection,
) {
const themeDirectionForReadingDirection = READING_DIRECTION_TO_THEME_DIRECTION[readingDirection];
const firstVisibleImageIndex = imageRefs.current.findIndex(
(image) =>
image &&
isPageInViewport(
image,
type,
// the pages aren't always properly scrolled to the top which results in the leading page to still be slightly
// visible (e.g. 0.0123px) breaking the "first visible image" detection
{
bottom: 1,
left: getOptionForDirection(0, 1, themeDirectionForReadingDirection),
right: getOptionForDirection(1, 0, themeDirectionForReadingDirection),
},
),
(image) => image && isPageInViewport(image, type, { truncateValues: true }),
);
const lastPage = imageRefs.current?.[imageRefs.current.length - 1];
const isEndReached = lastPage && isEndOfPageInViewport(lastPage, type, readingDirection);