Skip to content

Commit da9ff46

Browse files
committed
round up percent
1 parent 03188c6 commit da9ff46

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/loader.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,20 +443,24 @@ You can select a file to upload from the main page by clicking the 'Choose File.
443443
// Calculate percentage based on currentSize and totalSize
444444
// if data is available before actual percent
445445
const percent =
446-
this.percent || (this.currentSize && this.totalSize)
447-
? ((this.currentSize / this.totalSize) * 100).toFixed(0)
448-
: 0;
446+
this.currentSize && this.totalSize
447+
? Math.max(this.percent, (this.currentSize / this.totalSize) * 100)
448+
: this.percent;
449+
// Round up <1 percentages
450+
const displayPercent = percent ? Math.max(percent, 1) : undefined;
449451

450452
return html`
451453
<progress
452454
id="progress"
453455
class="progress is-primary is-large"
454-
value=${ifDefined(percent || undefined)}
456+
value=${ifDefined(displayPercent)}
455457
max="100"
456458
></progress>
457-
${percent
459+
${displayPercent
458460
? html`
459-
<label class="progress-label" for="progress">${percent}%</label>
461+
<label class="progress-label" for="progress"
462+
>${displayPercent}%</label
463+
>
460464
`
461465
: nothing}
462466
${this.currentSize && this.totalSize

0 commit comments

Comments
 (0)