From ac3233bfa4f70b996fe3a149279afc0fa410f6c0 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 11 Jun 2015 22:01:05 +0200 Subject: [PATCH] Use "private" properties in PDFViewer_scrollPageIntoView Currently in `PDFViewer_scrollPageIntoView`, we're accessing a number of properties in an indirect and overly complicated way. In particular, using `this.linkService.page` is a *very* roundabout way to access `this.currentPageNumber`. The reason for this appears to be entirely historical, since prior to PR 5361 the code was placed in `PDFPageView` (or `PageView` as it was called at the time). --- web/pdf_viewer.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index a719d6201..b82edd16b 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -455,14 +455,14 @@ var PDFViewer = (function pdfViewer() { var pageView = this._pages[pageNumber - 1]; if (this.isInPresentationMode) { - if (this.linkService.page !== pageView.id) { + if (this._currentPageNumber !== pageView.id) { // Avoid breaking getVisiblePages in presentation mode. - this.linkService.page = pageView.id; + this.currentPageNumber = pageView.id; return; } dest = null; // Fixes the case when PDF has different page sizes. - this._setScale(this.currentScaleValue, true); + this._setScale(this._currentScaleValue, true); } if (!dest) { scrollIntoView(pageView.div); @@ -510,13 +510,12 @@ var PDFViewer = (function pdfViewer() { y = dest[3]; width = dest[4] - x; height = dest[5] - y; - var viewerContainer = this.container; var hPadding = this.removePageBorders ? 0 : SCROLLBAR_PADDING; var vPadding = this.removePageBorders ? 0 : VERTICAL_PADDING; - widthScale = (viewerContainer.clientWidth - hPadding) / + widthScale = (this.container.clientWidth - hPadding) / width / CSS_UNITS; - heightScale = (viewerContainer.clientHeight - vPadding) / + heightScale = (this.container.clientHeight - vPadding) / height / CSS_UNITS; scale = Math.min(Math.abs(widthScale), Math.abs(heightScale)); break;