Skip to content

Commit

Permalink
Limit displayed progress width
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed May 22, 2024
1 parent 3d37e78 commit 3e4dd7f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/frontend/utils/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ export const createProgressBar = (parentElement = progressContainer) => {
}

const { total, n, elapsed, rate, prefix } = format;

const cappedN = Math.min(n, total)

const percent = 100 * (n / total);
progress.style.width = `${percent}%`
const percent = 100 * ( n / total );
progress.style.width = `${Math.min(100, percent)}%`

readout.innerText = `${n} / ${total} (${percent.toFixed(1)}%)`;

const remaining = rate && total ? (total - n) / rate : 0; // Seconds
const remaining = rate && total ? (total - Math.min(n, total)) / rate : 0; // Seconds

if (prefix) headerEl.innerText = prefix
metadataEl.innerText = `${elapsed.toFixed(1)}s elapsed, ${remaining.toFixed(1)}s remaining`;
Expand Down

0 comments on commit 3e4dd7f

Please sign in to comment.