Merge pull request #16379 from Snuffleupagus/sidebar-forceRendering
Simplify the `PDFSidebar.#forceRendering` method
This commit is contained in:
commit
2fab583fb4
@ -156,7 +156,7 @@ class PDFSidebar {
|
|||||||
*/
|
*/
|
||||||
switchView(view, forceOpen = false) {
|
switchView(view, forceOpen = false) {
|
||||||
const isViewChanged = view !== this.active;
|
const isViewChanged = view !== this.active;
|
||||||
let shouldForceRendering = false;
|
let forceRendering = false;
|
||||||
|
|
||||||
switch (view) {
|
switch (view) {
|
||||||
case SidebarView.NONE:
|
case SidebarView.NONE:
|
||||||
@ -166,7 +166,7 @@ class PDFSidebar {
|
|||||||
return; // Closing will trigger rendering and dispatch the event.
|
return; // Closing will trigger rendering and dispatch the event.
|
||||||
case SidebarView.THUMBS:
|
case SidebarView.THUMBS:
|
||||||
if (this.isOpen && isViewChanged) {
|
if (this.isOpen && isViewChanged) {
|
||||||
shouldForceRendering = true;
|
forceRendering = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SidebarView.OUTLINE:
|
case SidebarView.OUTLINE:
|
||||||
@ -224,9 +224,9 @@ class PDFSidebar {
|
|||||||
this.open();
|
this.open();
|
||||||
return; // Opening will trigger rendering and dispatch the event.
|
return; // Opening will trigger rendering and dispatch the event.
|
||||||
}
|
}
|
||||||
if (shouldForceRendering) {
|
if (forceRendering) {
|
||||||
this.#updateThumbnailViewer();
|
this.#updateThumbnailViewer();
|
||||||
this.#forceRendering();
|
this.onToggled();
|
||||||
}
|
}
|
||||||
if (isViewChanged) {
|
if (isViewChanged) {
|
||||||
this.#dispatchEvent();
|
this.#dispatchEvent();
|
||||||
@ -246,7 +246,7 @@ class PDFSidebar {
|
|||||||
if (this.active === SidebarView.THUMBS) {
|
if (this.active === SidebarView.THUMBS) {
|
||||||
this.#updateThumbnailViewer();
|
this.#updateThumbnailViewer();
|
||||||
}
|
}
|
||||||
this.#forceRendering();
|
this.onToggled();
|
||||||
this.#dispatchEvent();
|
this.#dispatchEvent();
|
||||||
|
|
||||||
this.#hideUINotification();
|
this.#hideUINotification();
|
||||||
@ -263,7 +263,7 @@ class PDFSidebar {
|
|||||||
this.outerContainer.classList.add("sidebarMoving");
|
this.outerContainer.classList.add("sidebarMoving");
|
||||||
this.outerContainer.classList.remove("sidebarOpen");
|
this.outerContainer.classList.remove("sidebarOpen");
|
||||||
|
|
||||||
this.#forceRendering();
|
this.onToggled();
|
||||||
this.#dispatchEvent();
|
this.#dispatchEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,16 +286,6 @@ class PDFSidebar {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#forceRendering() {
|
|
||||||
if (this.onToggled) {
|
|
||||||
this.onToggled();
|
|
||||||
} else {
|
|
||||||
// Fallback
|
|
||||||
this.pdfViewer.forceRendering();
|
|
||||||
this.pdfThumbnailViewer.forceRendering();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#updateThumbnailViewer() {
|
#updateThumbnailViewer() {
|
||||||
const { pdfViewer, pdfThumbnailViewer } = this;
|
const { pdfViewer, pdfThumbnailViewer } = this;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user