Refactor page loader to use a dedicated JS class

Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
Cursor Agent
2025-12-21 22:04:58 +00:00
co-authored by mathieumoran1
parent 6d7269f331
commit 1bc65ebd77
4 changed files with 169 additions and 62 deletions
+9 -5
View File
@@ -63,12 +63,16 @@ function createPageLoader(options = {}) {
function ensureMounted() {
if (removed) return;
if (!overlay.isConnected) {
updateOverlayTopOffset();
document.body.classList.add('page-loading');
document.body.appendChild(overlay);
// IMPORTANT: even if the overlay is preloaded in HTML (already connected),
// we still need to compute the navbar offset. Otherwise it defaults to 0px
// and the blur covers the header.
updateOverlayTopOffset();
document.body.classList.add('page-loading');
// Keep the overlay aligned if the navbar height changes (mobile collapse, resize, etc.)
if (!overlay.isConnected) document.body.appendChild(overlay);
// Keep the overlay aligned if the navbar height changes (mobile collapse, resize, etc.)
if (!navResizeObserver) {
const nav = document.querySelector('nav.navbar');
if (nav && typeof ResizeObserver !== 'undefined') {
try {