Spaces:
Running
Running
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); | |
} | |
} | |