Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix automatic zoom under spread mode #12700

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
let scale = parseFloat(value);

Expand All @@ -743,8 +757,9 @@ class BaseViewer {
[hPadding, vPadding] = [vPadding, hPadding]; // Swap the padding values.
}
const pageWidthScale =
((this.container.clientWidth - hPadding) / currentPage.width) *
currentPage.scale;
(((this.container.clientWidth - hPadding) / currentPage.width) *
currentPage.scale) /
this._pageWidthScaleFactor;
const pageHeightScale =
((this.container.clientHeight - vPadding) / currentPage.height) *
currentPage.scale;
Expand Down Expand Up @@ -1473,6 +1488,9 @@ class BaseViewer {
if (!pageNumber) {
return;
}
if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
this._setScale(this._currentScaleValue, true);
}
this._setCurrentPageNumber(pageNumber, /* resetCurrentPageView = */ true);
this.update();
}
Expand Down
4 changes: 4 additions & 0 deletions web/pdf_single_page_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class PDFSinglePageViewer extends BaseViewer {
return shadow(this, "_viewerElement", this._shadowViewer);
}

get _pageWidthScaleFactor() {
return 1;
}

_resetView() {
super._resetView();
this._previousPageNumber = 1;
Expand Down