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.
This commit is contained in:
Jonas Jenwald 2017-06-17 13:14:36 +02:00
parent 0c93dee0de
commit e4d032c5c7

View File

@ -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;