Revert "Remove per-draw canvas clones; title nav cap + right-page-number labels"

This reverts commit 0f66dae4eb.
This commit is contained in:
2026-06-20 07:37:12 +02:00
parent 0f66dae4eb
commit 7f60ce0d63
3 changed files with 29 additions and 43 deletions
+9 -34
View File
@@ -1950,21 +1950,14 @@ function getCurrentPagePosition() {
function getMaxNavigableSpread() {
const spreadCount = Math.max(1, Math.round(Number(bookPaginationState.spreadCount || 1)));
const visitedSpread = pageToSpreadIndex(maxVisitedPagePosition);
// Body content starts at page index 3 (after the blank/title/blank frontmatter). Until any
// content is written the book stays on the title spread — no flipping forward into blank
// leaves. Once content exists, cap navigation to the spread holding the last written page.
const writtenPageLimit = Math.max(0, Number(bookPaginationState.writtenPageLimit || 0));
const contentSpread = writtenPageLimit >= 3 ? pageToSpreadIndex(writtenPageLimit) : 0;
return Math.max(0, Math.min(visitedSpread, contentSpread, spreadCount - 1));
return Math.max(0, Math.min(visitedSpread, spreadCount - 1));
}
// Title spread reads 0; every other spread reads the printed page number of its right page.
// The page-number readout shows the odd (right) page of the visible pair, or 0 at the
// title spread.
function spreadPageLabel(spreadIndex) {
const spread = Math.max(0, Math.round(Number(spreadIndex || 0)));
if (spread <= 0) return '0';
const rightPageIndex = spreadPageIndices(spread).right;
const pageNumber = getPaginationPageMeta(rightPageIndex)?.pageNumber;
return pageNumber != null ? String(pageNumber) : '0';
return spread <= 0 ? '0' : String(spread * 2 + 1);
}
function scheduleBookRebuild(reason = 'scheduled') {
@@ -2137,16 +2130,6 @@ function ensureBottomNavigation() {
}
function navigateToSpread(targetSpread) {
if (isManualBookNavigationBusy()) {
markPageTextureTiming('navigation:blocked-busy', {
targetSpread,
activeFlips: activeFlips.length,
revealActive: hasActivePageReveal(),
playbackActive: document.documentElement.dataset.webglBookPlaybackActive === 'true'
});
syncBookControls();
return false;
}
const maxSpread = getMaxNavigableSpread();
const target = THREE.MathUtils.clamp(Math.round(Number(targetSpread || 0)), 0, maxSpread);
const currentSpread = Math.max(0, Math.round(Number(bookPaginationState.spreadIndex || 0)));
@@ -2176,7 +2159,7 @@ function navigateByPageDelta(delta) {
}
function syncBookControls() {
const busy = isManualBookNavigationBusy();
const busy = activeFlips.length > 0;
if (progressInput) progressInput.value = readingProgress.toFixed(3);
if (progressValue) progressValue.textContent = readingProgress.toFixed(2);
if (pageCountInput) pageCountInput.value = String(bookPageCount);
@@ -2205,12 +2188,10 @@ function syncBottomNavigation() {
bottomNavigation.root.style.setProperty('--book-nav-reserve-start', '1');
bottomNavigation.root.dataset.bookSize = String(bookPageCount);
bottomNavigation.root.dataset.pageReserve = String(pageReserve);
const busy = isManualBookNavigationBusy();
bottomNavigation.slider.disabled = busy;
bottomNavigation.startButton.disabled = busy || currentSpread <= 0;
bottomNavigation.backButton.disabled = busy || currentSpread <= 0;
bottomNavigation.forwardButton.disabled = busy || currentSpread >= maxSpread;
bottomNavigation.endButton.disabled = busy || currentSpread >= maxSpread;
bottomNavigation.startButton.disabled = activeFlips.length > 0 || currentSpread <= 0;
bottomNavigation.backButton.disabled = activeFlips.length > 0 || currentSpread <= 0;
bottomNavigation.forwardButton.disabled = activeFlips.length > 0 || currentSpread >= maxSpread;
bottomNavigation.endButton.disabled = activeFlips.length > 0 || currentSpread >= maxSpread;
}
function handlePageTextureRecords(event) {
@@ -3358,12 +3339,6 @@ function hasActivePageReveal() {
});
}
function isManualBookNavigationBusy() {
return activeFlips.length > 0
|| hasActivePageReveal()
|| document.documentElement.dataset.webglBookPlaybackActive === 'true';
}
function applyResidentSpreadTextures(spreadIndex, reason = 'resident-spread', options = {}) {
const skipSides = Array.isArray(options.skipSides) ? options.skipSides : [];
const pageIndices = spreadPageIndices(spreadIndex);