Skip to content

Commit

Permalink
fix(ProgressBar): creating '_getProgressWidth' to remove repeat code
Browse files Browse the repository at this point in the history
  • Loading branch information
slhay28 committed Aug 2, 2023
1 parent 830951e commit a26d48f
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export default class ProgressBar extends Base {
}

_updateTextures() {
const p = this.w * this._progress;
const w = p <= 0 ? 0 : Math.min(p, this.w);

Check failure on line 62 in packages/@lightningjs/ui-components/src/components/ProgressBar/ProgressBar.js

View workflow job for this annotation

GitHub Actions / quality / lint-unit

Delete `⏎`

Check failure on line 62 in packages/@lightningjs/ui-components/src/components/ProgressBar/ProgressBar.js

View workflow job for this annotation

GitHub Actions / quality / lint-unit

Delete `⏎`
const w = this._getProgressWidth();

this._Bar.texture = lng.Tools.getRoundRect(
// getRoundRect adds 2 to the width
Expand All @@ -85,8 +85,9 @@ export default class ProgressBar extends Base {
}

_updateProgress() {

Check failure on line 87 in packages/@lightningjs/ui-components/src/components/ProgressBar/ProgressBar.js

View workflow job for this annotation

GitHub Actions / quality / lint-unit

Delete `⏎····`

Check failure on line 87 in packages/@lightningjs/ui-components/src/components/ProgressBar/ProgressBar.js

View workflow job for this annotation

GitHub Actions / quality / lint-unit

Delete `⏎····`
const p = this.w * this._progress;
const w = p <= 0 ? 0 : Math.min(p, this.w);

const w = this._getProgressWidth();

this._Progress.smooth = {
w: [w, this.style.animation],
alpha: Number(w > 0)
Expand Down Expand Up @@ -115,4 +116,10 @@ export default class ProgressBar extends Base {
}
return `${Math.round(progress * 100)}%`;
}

_getProgressWidth() {
const p = this.w * this._progress;
const w = p <= 0 ? 0 : Math.min(p, this.w);
return w;
}
}

0 comments on commit a26d48f

Please sign in to comment.