Fix infinite scroll loading previous chapter unintentionally on reader open

This was only was noticeable in case the transition page was disabled.
Due to potential layout shifts and scrolling the initial page into view, the infinite chapter logic got triggered and loaded the previous chapter.
This is not a 100% guarantee that it won't happen, slow devices might still run into this issue
This commit is contained in:
schroda
2026-06-16 18:02:08 +02:00
parent 5cdc161d46
commit eef5f762cb
3 changed files with 33 additions and 2 deletions

View File

@@ -82,3 +82,16 @@ export const getNextRotationValue = <Value>(
return values[(indexOfValue + 1) % values.length];
};
export const maybeExecuteWithDelay = (
action: () => void,
delay: number,
condition: boolean,
): NodeJS.Timeout | undefined => {
if (condition) {
return setTimeout(() => action(), delay);
}
action();
return undefined;
};