Handle closing transition pages in paged pagers for single page chapters
In case a chapter only has a single page and the previous/next transition page was visible, it was not possible to go back to the chapters page, since it just opened the previous/next chapter instead
This commit is contained in:
@@ -378,53 +378,47 @@ export class ReaderControls {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const areContinuousPagerTransitionPagesVisible =
|
||||||
|
isContinuousReadingModeActive && isATransitionPageVisibleFlag;
|
||||||
|
const isPreviousTransitionPageVisible =
|
||||||
|
(!isContinuousReadingModeActive && transitionPageMode === ReaderTransitionPageMode.PREVIOUS) ||
|
||||||
|
areContinuousPagerTransitionPagesVisible;
|
||||||
|
const isNextTransitionPageVisible =
|
||||||
|
(!isContinuousReadingModeActive && transitionPageMode === ReaderTransitionPageMode.NEXT) ||
|
||||||
|
areContinuousPagerTransitionPagesVisible;
|
||||||
|
|
||||||
const shouldOpenPreviousChapter =
|
const shouldOpenPreviousChapter =
|
||||||
isFirstPage && isATransitionPageVisibleFlag && convertedPage === 'previous' && !!previousChapter;
|
isFirstPage && isPreviousTransitionPageVisible && convertedPage === 'previous' && !!previousChapter;
|
||||||
if (shouldOpenPreviousChapter) {
|
if (shouldOpenPreviousChapter) {
|
||||||
openChapter('previous');
|
openChapter('previous');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldOpenNextChapter =
|
const shouldOpenNextChapter =
|
||||||
isLastPage && isATransitionPageVisibleFlag && convertedPage === 'next' && !!nextChapter;
|
isLastPage && isNextTransitionPageVisible && convertedPage === 'next' && !!nextChapter;
|
||||||
if (shouldOpenNextChapter) {
|
if (shouldOpenNextChapter) {
|
||||||
openChapter('next');
|
openChapter('next');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isPreviousMode = convertedPage === 'previous';
|
||||||
|
|
||||||
const needToHideTransitionPage = isATransitionPageVisibleFlag && !isContinuousReadingModeActive;
|
const needToHideTransitionPage = isATransitionPageVisibleFlag && !isContinuousReadingModeActive;
|
||||||
switch (convertedPage) {
|
if (needToHideTransitionPage) {
|
||||||
case 'previous':
|
hideTransitionPage();
|
||||||
if (isFirstPage) {
|
setPageToScrollToIndex(isPreviousMode ? indexOfLastPage : indexOfFirstPage);
|
||||||
setTransitionPageMode(ReaderTransitionPageMode.PREVIOUS);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needToHideTransitionPage) {
|
|
||||||
hideTransitionPage();
|
|
||||||
setPageToScrollToIndex(indexOfLastPage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPageToScrollToIndex(previousPageIndex);
|
|
||||||
break;
|
|
||||||
case 'next':
|
|
||||||
if (isLastPage) {
|
|
||||||
setTransitionPageMode(ReaderTransitionPageMode.NEXT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needToHideTransitionPage) {
|
|
||||||
hideTransitionPage();
|
|
||||||
setPageToScrollToIndex(indexOfFirstPage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPageToScrollToIndex(nextPageIndex);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unexpected "offset" (${page})`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const needToOpenTransitionPage = isFirstPage || isLastPage;
|
||||||
|
if (needToOpenTransitionPage) {
|
||||||
|
setTransitionPageMode(
|
||||||
|
isPreviousMode ? ReaderTransitionPageMode.PREVIOUS : ReaderTransitionPageMode.NEXT,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPageToScrollToIndex(isPreviousMode ? previousPageIndex : nextPageIndex);
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
direction,
|
direction,
|
||||||
|
|||||||
Reference in New Issue
Block a user