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:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user