-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Scroll to current Chapter #1101
Fix: Scroll to current Chapter #1101
Conversation
Does it fix this too? |
Yes, this issue resulted from memoizing the index of the current chapter. The problem was that it returned 0 at first, because the chapter list hasn't been loaded yet. That is why it always points to the first chapter. |
src/screens/reader/components/ChapterDrawer/RenderListChapter.tsx
Outdated
Show resolved
Hide resolved
And I think using chapter id to detect the list item position is not correct for all novels. |
@nyagami Why? I use the findIndex function to return the index on the chapter drawer list if the id of the currently opened chapter matches the id of the chapter in the list. This has to work, else the navigation to the chapter would also be broken, since this also depends on the id of the chapter in the list. |
I mean this. if (
listAscending
? viewableItems[0].item.id < chapter.id
: viewableItems[0].item.id > chapter.id
)
interface ViewToken {
index: number;
isViewable: boolean;
item: string;
key: string;
timestamp: number;
} And I dont think navigation would be broken no matter what you are using. |
true, but I didn't know this existed since the type was missing. |
Ops, I forgot the custom page novels. you can try the test Hako plugin. |
I tested it now for a bit with a few novels and haven't encountered any problems. |
func: () => { | ||
listRef.current?.scrollToIndex({ index: 0, animated: true }); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using index (undefinded if scroll to end) instead of a callback is better.
const scroll = useCallback((index?: number) => {
//scroll here
}, [listRef.current]);
Also, moving the ListFooter to this file and call scroll callback
directly in button oppress could be cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now refactored the file and I think I got what you meant. At least the file is now definitly cleaner.
Cleaned ChapterDrawer and fixed the Scroll to current Chapter behaviour.