Merge pull request #15992 from calixteman/remove_loading_icon
Remove the loading icon div and replace it by a pure css solution using :after.
This commit is contained in:
commit
1ba1b8c711
@ -207,7 +207,6 @@ page_scale_actual=Actual Size
|
|||||||
page_scale_percent={{scale}}%
|
page_scale_percent={{scale}}%
|
||||||
|
|
||||||
# Loading indicator messages
|
# Loading indicator messages
|
||||||
loading=Loading…
|
|
||||||
loading_error=An error occurred while loading the PDF.
|
loading_error=An error occurred while loading the PDF.
|
||||||
invalid_file_error=Invalid or corrupted PDF file.
|
invalid_file_error=Invalid or corrupted PDF file.
|
||||||
missing_file_error=Missing PDF file.
|
missing_file_error=Missing PDF file.
|
||||||
|
@ -57,7 +57,6 @@ const DEFAULT_L10N_STRINGS = {
|
|||||||
page_scale_actual: "Actual Size",
|
page_scale_actual: "Actual Size",
|
||||||
page_scale_percent: "{{scale}}%",
|
page_scale_percent: "{{scale}}%",
|
||||||
|
|
||||||
loading: "Loading…",
|
|
||||||
loading_error: "An error occurred while loading the PDF.",
|
loading_error: "An error occurred while loading the PDF.",
|
||||||
invalid_file_error: "Invalid or corrupted PDF file.",
|
invalid_file_error: "Invalid or corrupted PDF file.",
|
||||||
missing_file_error: "Missing PDF file.",
|
missing_file_error: "Missing PDF file.",
|
||||||
|
@ -117,6 +117,8 @@ class PDFPageView {
|
|||||||
|
|
||||||
#layerProperties = null;
|
#layerProperties = null;
|
||||||
|
|
||||||
|
#loadingId = null;
|
||||||
|
|
||||||
#previousRotation = null;
|
#previousRotation = null;
|
||||||
|
|
||||||
#renderingState = RenderingStates.INITIAL;
|
#renderingState = RenderingStates.INITIAL;
|
||||||
@ -232,21 +234,34 @@ class PDFPageView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set renderingState(state) {
|
set renderingState(state) {
|
||||||
|
if (state === this.#renderingState) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.#renderingState = state;
|
this.#renderingState = state;
|
||||||
|
|
||||||
|
if (this.#loadingId) {
|
||||||
|
clearTimeout(this.#loadingId);
|
||||||
|
this.#loadingId = null;
|
||||||
|
}
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case RenderingStates.INITIAL:
|
case RenderingStates.INITIAL:
|
||||||
case RenderingStates.PAUSED:
|
case RenderingStates.PAUSED:
|
||||||
this.loadingIconDiv?.classList.add("notVisible");
|
this.div.classList.remove("loading");
|
||||||
break;
|
break;
|
||||||
case RenderingStates.RUNNING:
|
case RenderingStates.RUNNING:
|
||||||
this.loadingIconDiv?.classList.remove("notVisible");
|
this.div.classList.add("loadingIcon");
|
||||||
|
this.#loadingId = setTimeout(() => {
|
||||||
|
// Adding the loading class is slightly postponed in order to not have
|
||||||
|
// it with loadingIcon.
|
||||||
|
// If we don't do that the visibility of the background is changed but
|
||||||
|
// the transition isn't triggered.
|
||||||
|
this.div.classList.add("loading");
|
||||||
|
this.#loadingId = null;
|
||||||
|
}, 0);
|
||||||
break;
|
break;
|
||||||
case RenderingStates.FINISHED:
|
case RenderingStates.FINISHED:
|
||||||
if (this.loadingIconDiv) {
|
this.div.classList.remove("loadingIcon", "loading");
|
||||||
this.loadingIconDiv.remove();
|
|
||||||
delete this.loadingIconDiv;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -468,7 +483,6 @@ class PDFPageView {
|
|||||||
case annotationEditorLayerNode:
|
case annotationEditorLayerNode:
|
||||||
case xfaLayerNode:
|
case xfaLayerNode:
|
||||||
case textLayerNode:
|
case textLayerNode:
|
||||||
case this.loadingIconDiv:
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
node.remove();
|
node.remove();
|
||||||
@ -511,16 +525,6 @@ class PDFPageView {
|
|||||||
this.paintedViewportMap.delete(this.svg);
|
this.paintedViewportMap.delete(this.svg);
|
||||||
delete this.svg;
|
delete this.svg;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update({
|
update({
|
||||||
|
@ -150,22 +150,28 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pdfViewer .page .loadingIcon {
|
.pdfViewer .page.loadingIcon:after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: block;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
left: 0;
|
||||||
bottom: 0;
|
content: "";
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
background: url("images/loading-icon.gif") center no-repeat;
|
background: url("images/loading-icon.gif") center no-repeat;
|
||||||
visibility: visible;
|
visibility: hidden;
|
||||||
/* Using a delay with background-image doesn't work,
|
/* Using a delay with background-image doesn't work,
|
||||||
consequently we use the visibility. */
|
consequently we use the visibility. */
|
||||||
transition-property: visibility;
|
transition-property: visibility;
|
||||||
transition-delay: var(--loading-icon-delay);
|
transition-delay: var(--loading-icon-delay);
|
||||||
z-index: 5;
|
z-index: 5;
|
||||||
|
contain: strict;
|
||||||
}
|
}
|
||||||
.pdfViewer .page .loadingIcon.notVisible {
|
|
||||||
|
.pdfViewer .page.loading:after {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pdfViewer .page:not(.loading):after {
|
||||||
transition-property: none;
|
transition-property: none;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user