ready-xet-go / js /progress-bar.js
jsulz's picture
jsulz HF Staff
refactor - needs some more tlc
f0bb158
raw
history blame contribute delete
728 Bytes
export class ProgressBar {
constructor(elementId) {
this.element = document.getElementById(elementId);
this.currentProgress = 0;
}
animate(targetProgress) {
if (this.currentProgress < targetProgress) {
this.currentProgress++;
this.element.style.width = `${this.currentProgress}%`;
this.element.textContent = `${this.currentProgress}%`;
setTimeout(() => this.animate(targetProgress), 75);
}
}
init(repoData) {
const max_value = 100;
const current_status = Math.round((repoData[repoData.length - 1].xet_repos / repoData[repoData.length - 1].hub_repos) * max_value);
this.animate(current_status);
}
}