Skip to content

Commit

Permalink
Reset scale when update spread mode
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Dec 9, 2020
1 parent 7012702 commit b8b9ccf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
23 changes: 18 additions & 5 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 @@ -735,10 +749,6 @@ class BaseViewer {
if (!currentPage) {
return;
}
const factor =
this.spreadMode === SpreadMode.NONE || this._isScrollModeHorizontal
? 1
: 2;

const noPadding = this.isInPresentationMode || this.removePageBorders;
let hPadding = noPadding ? 0 : SCROLLBAR_PADDING;
Expand All @@ -750,7 +760,7 @@ class BaseViewer {
const pageWidthScale =
(((this.container.clientWidth - hPadding) / currentPage.width) *
currentPage.scale) /
factor;
this._pageWidthScaleFactor;
const pageHeightScale =
((this.container.clientHeight - vPadding) / currentPage.height) *
currentPage.scale;
Expand Down Expand Up @@ -1481,6 +1491,9 @@ class BaseViewer {
}
this._setCurrentPageNumber(pageNumber, /* resetCurrentPageView = */ true);
this.update();
if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
this._setScale(this._currentScaleValue, true);
}
}
}

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

0 comments on commit b8b9ccf

Please sign in to comment.