From 35179943db89b543b6d362fd0bf7fe0dced6243a Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 14 Dec 2022 18:13:09 +0100 Subject: [PATCH] Don't remove the loading icon from the DOM when a page is resetted --- web/pdf_page_view.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 0bdea2c7434b2e..b8a6a6ad8e38a8 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -430,6 +430,7 @@ class PDFPageView { case annotationEditorLayerNode: case xfaLayerNode: case textLayerNode: + case this.loadingIconDiv: continue; } node.remove(); @@ -473,8 +474,18 @@ class PDFPageView { delete this.svg; } - this.loadingIconDiv = document.createElement("div"); - this.loadingIconDiv.className = "loadingIcon notVisible"; + if (!this.loadingIconDiv) { + this.loadingIconDiv = document.createElement("div"); + this.loadingIconDiv.className = "loadingIcon notVisible"; + this.loadingIconDiv.setAttribute("role", "img"); + this.l10n.get("loading").then(msg => { + this.loadingIconDiv?.setAttribute("aria-label", msg); + }); + div.append(this.loadingIconDiv); + } else { + this.toggleLoadingIconSpinner(); + } + if ( (typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || GENERIC")) && @@ -482,11 +493,6 @@ class PDFPageView { ) { this.toggleLoadingIconSpinner(/* viewVisible = */ true); } - this.loadingIconDiv.setAttribute("role", "img"); - this.l10n.get("loading").then(msg => { - this.loadingIconDiv?.setAttribute("aria-label", msg); - }); - div.append(this.loadingIconDiv); } update({ scale = 0, rotation = null, optionalContentConfigPromise = null }) { @@ -725,6 +731,7 @@ class PDFPageView { return Promise.reject(new Error("pdfPage is not loaded")); } + this.toggleLoadingIconSpinner(/* viewVisible = */ true); this.renderingState = RenderingStates.RUNNING; // Wrap the canvas so that if it has a CSS transform for high DPI the