brush-cost: prevent percentage values from overflowing

This commit is contained in:
リキ萌え 2024-10-25 21:45:51 +02:00
parent 913d65b0a8
commit 10d384f3d7

View file

@ -17,7 +17,7 @@ class Gauge extends HTMLElement {
setValue(value, valueMax) {
let clampedNormalized = Math.max(0, Math.min(1, value / valueMax));
this.style.setProperty("--progress", `${clampedNormalized * 100}%`);
this.title = `${this.label}: ${value} / ${valueMax} (${Math.ceil((value / valueMax) * 100)}%)`;
this.title = `${this.label}: ${value} / ${valueMax} (${Math.ceil(clampedNormalized * 100)}%)`;
}
}