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. |
|
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.
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.
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.