Move reader "scrollbar state" to "reader store"
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
import { memo } from 'react';
|
||||
import { withPropsFrom } from '@/base/hoc/withPropsFrom.tsx';
|
||||
import { useReaderInfiniteScrollUpdateChapter } from '@/features/reader/infinite-scroll/useReaderInfiniteScrollUpdateChapter.ts';
|
||||
import { IReaderSettings, TReaderScrollbarContext } from '@/features/reader/Reader.types.ts';
|
||||
import { IReaderSettings } from '@/features/reader/Reader.types.ts';
|
||||
import { ReaderControls } from '@/features/reader/services/ReaderControls.ts';
|
||||
import { ReaderService } from '@/features/reader/services/ReaderService.ts';
|
||||
import { ChapterIdInfo } from '@/features/chapter/Chapter.types.ts';
|
||||
@@ -26,12 +26,9 @@ const BaseReaderInfiniteScrollUpdateChapter = ({
|
||||
isNextChapterVisible,
|
||||
imageWrapper,
|
||||
openChapter,
|
||||
scrollbarXSize,
|
||||
scrollbarYSize,
|
||||
scrollElement,
|
||||
shouldShowTransitionPage,
|
||||
}: Pick<IReaderSettings, 'shouldShowTransitionPage'> &
|
||||
Pick<TReaderScrollbarContext, 'scrollbarXSize' | 'scrollbarYSize'> &
|
||||
Pick<IReaderSettings, 'readingMode' | 'readingDirection' | 'shouldUseInfiniteScroll'> & {
|
||||
chapterId: ChapterIdInfo['id'];
|
||||
previousChapterId?: ChapterIdInfo['id'];
|
||||
@@ -54,8 +51,6 @@ const BaseReaderInfiniteScrollUpdateChapter = ({
|
||||
shouldUseInfiniteScroll,
|
||||
openChapter,
|
||||
imageWrapper,
|
||||
scrollbarXSize,
|
||||
scrollbarYSize,
|
||||
scrollElement,
|
||||
shouldShowTransitionPage,
|
||||
);
|
||||
@@ -70,8 +65,6 @@ const BaseReaderInfiniteScrollUpdateChapter = ({
|
||||
shouldUseInfiniteScroll,
|
||||
openChapter,
|
||||
imageWrapper,
|
||||
scrollbarXSize,
|
||||
scrollbarYSize,
|
||||
scrollElement,
|
||||
shouldShowTransitionPage,
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
import { READING_DIRECTION_TO_THEME_DIRECTION } from '@/features/reader/settings/ReaderSettings.constants.tsx';
|
||||
import { getOptionForDirection } from '@/features/theme/services/ThemeCreator.ts';
|
||||
import { useIntersectionObserver } from '@/base/hooks/useIntersectionObserver.tsx';
|
||||
import { getReaderStore } from '@/features/reader/ReaderStore.ts';
|
||||
|
||||
interface ElementIntersection {
|
||||
start: boolean;
|
||||
@@ -246,8 +247,6 @@ export const useReaderInfiniteScrollUpdateChapter = (
|
||||
shouldUseInfiniteScroll: boolean,
|
||||
openChapter: ReturnType<typeof ReaderControls.useOpenChapter>,
|
||||
image: HTMLElement | null,
|
||||
scrollbarXSize: number,
|
||||
scrollbarYSize: number,
|
||||
scrollElement: HTMLElement | null,
|
||||
shouldShowTransitionPage: boolean,
|
||||
) => {
|
||||
@@ -321,8 +320,8 @@ export const useReaderInfiniteScrollUpdateChapter = (
|
||||
const elementIntersectionInfo = getElementIntersectionInfo(
|
||||
readingDirection,
|
||||
entry.target.getBoundingClientRect(),
|
||||
scrollbarXSize,
|
||||
scrollbarYSize,
|
||||
getReaderStore().scrollbar.scrollbarXSize,
|
||||
getReaderStore().scrollbar.scrollbarYSize,
|
||||
);
|
||||
const { start: isStartIntersecting, end: isEndIntersecting } = getElementIntersection(
|
||||
elementIntersectionInfo,
|
||||
@@ -362,8 +361,6 @@ export const useReaderInfiniteScrollUpdateChapter = (
|
||||
shouldUseInfiniteScroll,
|
||||
shouldShowTransitionPage,
|
||||
openChapter,
|
||||
scrollbarXSize,
|
||||
scrollbarYSize,
|
||||
],
|
||||
),
|
||||
useMemo(
|
||||
|
||||
Reference in New Issue
Block a user