Merge pull request #12700 from calixteman/12699

Fix automatic zoom under spread mode
This commit is contained in:
Tim van der Meij 2020-12-14 23:39:48 +01:00 committed by GitHub
commit a825b9195b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -725,6 +725,20 @@ class BaseViewer {
} }
} }
/**
* @private
*/
get _pageWidthScaleFactor() {
if (
this.spreadMode !== SpreadMode.NONE &&
this.scrollMode !== ScrollMode.HORIZONTAL &&
!this.isInPresentationMode
) {
return 2;
}
return 1;
}
_setScale(value, noScroll = false) { _setScale(value, noScroll = false) {
let scale = parseFloat(value); let scale = parseFloat(value);
@ -743,8 +757,9 @@ class BaseViewer {
[hPadding, vPadding] = [vPadding, hPadding]; // Swap the padding values. [hPadding, vPadding] = [vPadding, hPadding]; // Swap the padding values.
} }
const pageWidthScale = const pageWidthScale =
((this.container.clientWidth - hPadding) / currentPage.width) * (((this.container.clientWidth - hPadding) / currentPage.width) *
currentPage.scale; currentPage.scale) /
this._pageWidthScaleFactor;
const pageHeightScale = const pageHeightScale =
((this.container.clientHeight - vPadding) / currentPage.height) * ((this.container.clientHeight - vPadding) / currentPage.height) *
currentPage.scale; currentPage.scale;
@ -1473,6 +1488,9 @@ class BaseViewer {
if (!pageNumber) { if (!pageNumber) {
return; return;
} }
if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
this._setScale(this._currentScaleValue, true);
}
this._setCurrentPageNumber(pageNumber, /* resetCurrentPageView = */ true); this._setCurrentPageNumber(pageNumber, /* resetCurrentPageView = */ true);
this.update(); this.update();
} }

View File

@ -35,6 +35,10 @@ class PDFSinglePageViewer extends BaseViewer {
return shadow(this, "_viewerElement", this._shadowViewer); return shadow(this, "_viewerElement", this._shadowViewer);
} }
get _pageWidthScaleFactor() {
return 1;
}
_resetView() { _resetView() {
super._resetView(); super._resetView();
this._previousPageNumber = 1; this._previousPageNumber = 1;