From 8507fdec3e186cca207c526b1f31bb8148a97e60 Mon Sep 17 00:00:00 2001 From: Lukas Stabe Date: Sun, 9 Mar 2025 10:17:40 +0100 Subject: fix loading animation and row height jumping while loading dir sizes --- src/renderer.rs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/renderer.rs b/src/renderer.rs index 6a8b808..3f67695 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -687,21 +687,6 @@ fn page_header( }).then(resp => resp.ok ? resp.text() : "~") } - // Initialize shimmer effects for .size-cell elements in .entry-type-directory rows - // - // TODO: Perhaps it'd be better to statically do this during html generation in - // entry_row()? - function initializeLoadingIndicators() { - const directoryCells = document.querySelectorAll('tr.entry-type-directory .size-cell'); - - directoryCells.forEach(cell => { - // Add a loading indicator to each cell - const loadingIndicator = document.createElement('div'); - loadingIndicator.className = 'loading-indicator'; - cell.appendChild(loadingIndicator); - }); - } - function updateSizeCells() { const directoryCells = document.querySelectorAll('tr.entry-type-directory .size-cell'); @@ -712,12 +697,10 @@ fn page_header( // First check our local cache if (target in dirSizeCache) { - cell.innerHTML = ''; - cell.textContent = dirSizeCache[target]; + cell.dataset.size = dirSizeCache[target]; } else { fetchDirSize(target).then(dir_size => { - cell.innerHTML = ''; - cell.textContent = dir_size; + cell.dataset.size = dir_size; dirSizeCache[target] = dir_size; }) .catch(error => console.error("Error fetching dir size:", error)); @@ -725,7 +708,6 @@ fn page_header( }) } setInterval(updateSizeCells, 1000); - window.addEventListener('load', initializeLoadingIndicators); "#)) } -- cgit v1.2.3