Remove the view
-specific getters in the PDFSidebar
class
With the exception of `isThumbnailViewVisible`, these getters are completely unused. Generally speaking, using the `visibleView`-getter directly works just as well and seems (at least to me) to be overall preferable considering how our classes are usually implemented.
This commit is contained in:
parent
e6a0a953e8
commit
13fda7caeb
16
web/app.js
16
web/app.js
@ -1765,7 +1765,7 @@ const PDFViewerApplication = {
|
|||||||
forceRendering() {
|
forceRendering() {
|
||||||
this.pdfRenderingQueue.printing = !!this.printService;
|
this.pdfRenderingQueue.printing = !!this.printService;
|
||||||
this.pdfRenderingQueue.isThumbnailViewEnabled =
|
this.pdfRenderingQueue.isThumbnailViewEnabled =
|
||||||
this.pdfSidebar.isThumbnailViewVisible;
|
this.pdfSidebar.visibleView === SidebarView.THUMBS;
|
||||||
this.pdfRenderingQueue.renderHighestPriority();
|
this.pdfRenderingQueue.renderHighestPriority();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2261,7 +2261,7 @@ function webViewerPageRendered({ pageNumber, error }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use the rendered page to set the corresponding thumbnail image.
|
// Use the rendered page to set the corresponding thumbnail image.
|
||||||
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
|
if (PDFViewerApplication.pdfSidebar.visibleView === SidebarView.THUMBS) {
|
||||||
const pageView = PDFViewerApplication.pdfViewer.getPageView(
|
const pageView = PDFViewerApplication.pdfViewer.getPageView(
|
||||||
/* index = */ pageNumber - 1
|
/* index = */ pageNumber - 1
|
||||||
);
|
);
|
||||||
@ -2338,21 +2338,19 @@ function webViewerPresentationModeChanged(evt) {
|
|||||||
PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
|
PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerSidebarViewChanged(evt) {
|
function webViewerSidebarViewChanged({ view }) {
|
||||||
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled =
|
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled =
|
||||||
PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
|
view === SidebarView.THUMBS;
|
||||||
|
|
||||||
if (PDFViewerApplication.isInitialViewSet) {
|
if (PDFViewerApplication.isInitialViewSet) {
|
||||||
// Only update the storage when the document has been loaded *and* rendered.
|
// Only update the storage when the document has been loaded *and* rendered.
|
||||||
PDFViewerApplication.store?.set("sidebarView", evt.view).catch(() => {
|
PDFViewerApplication.store?.set("sidebarView", view).catch(() => {
|
||||||
// Unable to write to storage.
|
// Unable to write to storage.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerUpdateViewarea(evt) {
|
function webViewerUpdateViewarea({ location }) {
|
||||||
const location = evt.location;
|
|
||||||
|
|
||||||
if (PDFViewerApplication.isInitialViewSet) {
|
if (PDFViewerApplication.isInitialViewSet) {
|
||||||
// Only update the storage when the document has been loaded *and* rendered.
|
// Only update the storage when the document has been loaded *and* rendered.
|
||||||
PDFViewerApplication.store
|
PDFViewerApplication.store
|
||||||
@ -2587,7 +2585,7 @@ function webViewerPageChanging({ pageNumber, pageLabel }) {
|
|||||||
PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
|
PDFViewerApplication.toolbar.setPageNumber(pageNumber, pageLabel);
|
||||||
PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
|
PDFViewerApplication.secondaryToolbar.setPageNumber(pageNumber);
|
||||||
|
|
||||||
if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
|
if (PDFViewerApplication.pdfSidebar.visibleView === SidebarView.THUMBS) {
|
||||||
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
|
PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(pageNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,22 +120,6 @@ class PDFSidebar {
|
|||||||
return this.isOpen ? this.active : SidebarView.NONE;
|
return this.isOpen ? this.active : SidebarView.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isThumbnailViewVisible() {
|
|
||||||
return this.isOpen && this.active === SidebarView.THUMBS;
|
|
||||||
}
|
|
||||||
|
|
||||||
get isOutlineViewVisible() {
|
|
||||||
return this.isOpen && this.active === SidebarView.OUTLINE;
|
|
||||||
}
|
|
||||||
|
|
||||||
get isAttachmentsViewVisible() {
|
|
||||||
return this.isOpen && this.active === SidebarView.ATTACHMENTS;
|
|
||||||
}
|
|
||||||
|
|
||||||
get isLayersViewVisible() {
|
|
||||||
return this.isOpen && this.active === SidebarView.LAYERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} view - The sidebar view that should become visible,
|
* @param {number} view - The sidebar view that should become visible,
|
||||||
* must be one of the values in {SidebarView}.
|
* must be one of the values in {SidebarView}.
|
||||||
@ -447,7 +431,7 @@ class PDFSidebar {
|
|||||||
this.eventBus._on("presentationmodechanged", evt => {
|
this.eventBus._on("presentationmodechanged", evt => {
|
||||||
if (
|
if (
|
||||||
evt.state === PresentationModeState.NORMAL &&
|
evt.state === PresentationModeState.NORMAL &&
|
||||||
this.isThumbnailViewVisible
|
this.visibleView === SidebarView.THUMBS
|
||||||
) {
|
) {
|
||||||
this._updateThumbnailViewer();
|
this._updateThumbnailViewer();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user