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).
This commit is contained in:
Jonas Jenwald 2015-06-11 22:01:05 +02:00
parent 56e3a66c16
commit ac3233bfa4

View File

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