mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Stop using downloadComplete
in PDFViewerApplication.progress
This was only necessary to prevent (unlikely) visual glitches when `disableAutoFetch = true` is being used.
However, it turns out that we can move this functionality into the `ProgressBar` class instead by checking if the entire PDF document has loaded. This works since the API is always reporting 100% loading progress regardless of how the document was loaded; see [this code](ed83d7c5e1/src/display/api.js (L2735-L2740)
).
This commit is contained in:
parent
ed83d7c5e1
commit
006242489d
2 changed files with 2 additions and 7 deletions
|
@ -1188,17 +1188,12 @@ const PDFViewerApplication = {
|
|||
},
|
||||
|
||||
progress(level) {
|
||||
if (!this.loadingBar || this.downloadComplete) {
|
||||
// Don't accidentally show the loading bar again when the entire file has
|
||||
// already been fetched (only an issue when disableAutoFetch is enabled).
|
||||
return;
|
||||
}
|
||||
const percent = Math.round(level * 100);
|
||||
// When we transition from full request to range requests, it's possible
|
||||
// that we discard some of the loaded data. This can cause the loading
|
||||
// bar to move backwards. So prevent this by only updating the bar if it
|
||||
// increases.
|
||||
if (percent <= this.loadingBar.percent) {
|
||||
if (!this.loadingBar || percent <= this.loadingBar.percent) {
|
||||
return;
|
||||
}
|
||||
this.loadingBar.percent = percent;
|
||||
|
|
|
@ -740,7 +740,7 @@ class ProgressBar {
|
|||
}
|
||||
|
||||
setDisableAutoFetch(delay = /* ms = */ 5000) {
|
||||
if (isNaN(this.#percent)) {
|
||||
if (this.#percent === 100 || isNaN(this.#percent)) {
|
||||
return;
|
||||
}
|
||||
if (this.#disableAutoFetchTimeout) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue