diff --git a/static/js/app.js b/static/js/app.js index 83c238e..868dd26 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -3712,6 +3712,9 @@ async function applyPdfZoom(newZoom) { pdfSmartZoomPage(pdfCurrentPage); } else { await reRenderPdf(); + // Wait for two animation frames so the browser finishes layout + // before reading scrollHeight for position restoration + await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r))); if (contentEl2 && fraction > 0) { contentEl2.scrollTop = fraction * (contentEl2.scrollHeight - contentEl2.clientHeight); } @@ -3722,7 +3725,13 @@ async function reRenderPdf() { if (!currentPdfBuffer) return; const contentEl = $('reader-content'); if (!contentEl) return; + const overlay = $('reader-overlay'); + const loadingEl = document.createElement('div'); + loadingEl.className = 'pdf-loading-overlay'; + loadingEl.innerHTML = ''; + if (overlay) overlay.appendChild(loadingEl); await renderPdf(currentPdfBuffer, contentEl); + loadingEl.remove(); if (readerSettings.pdfPaginated) enterPdfPaginatedMode(); }