From e4d032c5c7c6b895ae2b66d69f03005f5b9fcf25 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 17 Jun 2017 13:14:36 +0200 Subject: [PATCH] Reset `pageRotation` and `downloadComplete` in `PDFViewerApplication.close` Currently, these properties are reset in what appears to be somewhat arbitrary locations (within the `load` and `open` methods respectively). The explanation is probably that both of these properties predates the existence of any centralized clean-up code in the viewer. Hence I think that it makes sense to move the resetting of these properties to the `close` method, since that improves the overview of what's actually cleaned-up/reset when changing documents in the viewer. --- web/app.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/web/app.js b/web/app.js index b5c30a4b5..29faa7543 100644 --- a/web/app.js +++ b/web/app.js @@ -136,6 +136,7 @@ var PDFViewerApplication = { l10n: null, pageRotation: 0, isInitialViewSet: false, + downloadComplete: false, viewerPrefs: { sidebarViewOnLoad: SidebarView.NONE, pdfBugEnabled: false, @@ -599,7 +600,9 @@ var PDFViewerApplication = { this.pdfDocumentProperties.setDocument(null, null); } this.store = null; + this.pageRotation = 0; this.isInitialViewSet = false; + this.downloadComplete = false; this.pdfSidebar.reset(); this.pdfOutlineViewer.reset(); @@ -669,8 +672,6 @@ var PDFViewerApplication = { } } - this.downloadComplete = false; - let loadingTask = getDocument(parameters); this.pdfLoadingTask = loadingTask; @@ -911,8 +912,6 @@ var PDFViewerApplication = { let pagesPromise = pdfViewer.pagesPromise; let onePageRendered = pdfViewer.onePageRendered; - this.pageRotation = 0; - let pdfThumbnailViewer = this.pdfThumbnailViewer; pdfThumbnailViewer.setDocument(pdfDocument); @@ -1241,8 +1240,11 @@ var PDFViewerApplication = { this.forceRendering(); }, - rotatePages: function pdfViewRotatePages(delta) { - var pageNumber = this.page; + rotatePages(delta) { + if (!this.pdfDocument) { + return; + } + let pageNumber = this.page; this.pageRotation = (this.pageRotation + 360 + delta) % 360; this.pdfViewer.pagesRotation = this.pageRotation; this.pdfThumbnailViewer.pagesRotation = this.pageRotation;