Move the disableAutoFetch functionality into the ProgressBar-class

It seems nicer overall, since we're exporting the `ProgressBar` in the viewer-components, to move this functionality into the `ProgressBar`-class itself rather than handling it "manually" in the default-viewer.
This commit is contained in:
Jonas Jenwald 2023-01-21 12:29:36 +01:00
parent 7b95788248
commit d7013bee54
2 changed files with 21 additions and 16 deletions

View file

@ -693,6 +693,8 @@ function clamp(v, min, max) {
class ProgressBar {
#classList = null;
#disableAutoFetchTimeout = null;
#percent = 0;
#visible = true;
@ -728,6 +730,21 @@ class ProgressBar {
}
}
setDisableAutoFetch(delay = /* ms = */ 5000) {
if (isNaN(this.#percent)) {
return;
}
if (this.#disableAutoFetchTimeout) {
clearTimeout(this.#disableAutoFetchTimeout);
}
this.show();
this.#disableAutoFetchTimeout = setTimeout(() => {
this.#disableAutoFetchTimeout = null;
this.hide();
}, delay);
}
hide() {
if (!this.#visible) {
return;