diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2025-03-09 16:10:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-09 16:10:35 +0000 |
commit | e4623647a5ae5dd1de39f35d4d686cc874f079cb (patch) | |
tree | e12cc6c715a79cb50c121531fdde531cf0bc63fa /src/renderer.rs | |
parent | Better formatting (diff) | |
parent | fix loading animation and row height jumping while loading dir sizes (diff) | |
download | miniserve-e4623647a5ae5dd1de39f35d4d686cc874f079cb.tar.gz miniserve-e4623647a5ae5dd1de39f35d4d686cc874f079cb.zip |
Merge pull request #1484 from ahti/animations
fix loading animation and row height jumping while loading dir sizes
Diffstat (limited to '')
-rw-r--r-- | src/renderer.rs | 22 |
1 files changed, 2 insertions, 20 deletions
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); "#)) } |