mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
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:
parent
7b95788248
commit
d7013bee54
2 changed files with 21 additions and 16 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue