Change the scrollMode/spreadMode to "private" properties on BaseViewer instances

This commit is contained in:
Jonas Jenwald 2018-06-29 14:14:11 +02:00
parent a9a93bd923
commit 9515f579c6
2 changed files with 14 additions and 14 deletions

View File

@ -162,8 +162,8 @@ class BaseViewer {
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
this.maxCanvasPixels = options.maxCanvasPixels;
this.l10n = options.l10n || NullL10n;
this.scrollMode = options.scrollMode || ScrollMode.VERTICAL;
this.spreadMode = options.spreadMode || SpreadMode.NONE;
this._scrollMode = options.scrollMode || ScrollMode.VERTICAL;
this._spreadMode = options.spreadMode || SpreadMode.NONE;
this.defaultRenderingQueue = !options.renderingQueue;
if (this.defaultRenderingQueue) {
@ -181,7 +181,7 @@ class BaseViewer {
if (this.removePageBorders) {
this.viewer.classList.add('removePageBorders');
}
if (this.scrollMode !== ScrollMode.VERTICAL) {
if (this._scrollMode !== ScrollMode.VERTICAL) {
this._updateScrollModeClasses();
}
}
@ -441,7 +441,7 @@ class BaseViewer {
bindOnAfterAndBeforeDraw(pageView);
this._pages.push(pageView);
}
if (this.spreadMode !== SpreadMode.NONE) {
if (this._spreadMode !== SpreadMode.NONE) {
this._regroupSpreads();
}
@ -1027,7 +1027,7 @@ class BaseViewer {
if (!Number.isInteger(mode) || !Object.values(ScrollMode).includes(mode)) {
throw new Error(`Invalid scroll mode: ${mode}`);
}
this.scrollMode = mode;
this._scrollMode = mode;
}
_updateScrollModeClasses() {
@ -1038,7 +1038,7 @@ class BaseViewer {
if (!Number.isInteger(mode) || !Object.values(SpreadMode).includes(mode)) {
throw new Error(`Invalid spread mode: ${mode}`);
}
this.spreadMode = mode;
this._spreadMode = mode;
}
_regroupSpreads() {

View File

@ -27,7 +27,7 @@ class PDFViewer extends BaseViewer {
const left = pageDiv.offsetLeft + pageDiv.clientLeft;
const right = left + pageDiv.clientWidth;
const { scrollLeft, clientWidth, } = this.container;
if (this.scrollMode === ScrollMode.HORIZONTAL ||
if (this._scrollMode === ScrollMode.HORIZONTAL ||
left < scrollLeft || right > scrollLeft + clientWidth) {
pageSpot = { left: 0, top: 0, };
}
@ -38,7 +38,7 @@ class PDFViewer extends BaseViewer {
_getVisiblePages() {
if (!this.isInPresentationMode) {
return getVisibleElements(this.container, this._pages, true,
this.scrollMode === ScrollMode.HORIZONTAL);
this._scrollMode === ScrollMode.HORIZONTAL);
}
// The algorithm in getVisibleElements doesn't work in all browsers and
// configurations when presentation mode is active.
@ -91,11 +91,11 @@ class PDFViewer extends BaseViewer {
// Used to ensure that pre-rendering of the next/previous page works
// correctly, since Scroll/Spread modes are ignored in Presentation Mode.
return (this.isInPresentationMode ?
false : this.scrollMode === ScrollMode.HORIZONTAL);
false : this._scrollMode === ScrollMode.HORIZONTAL);
}
setScrollMode(mode) {
if (mode === this.scrollMode) {
if (mode === this._scrollMode) {
return;
}
super.setScrollMode(mode);
@ -118,7 +118,7 @@ class PDFViewer extends BaseViewer {
}
_updateScrollModeClasses() {
const { scrollMode, viewer, } = this;
const scrollMode = this._scrollMode, viewer = this.viewer;
if (scrollMode === ScrollMode.HORIZONTAL) {
viewer.classList.add('scrollHorizontal');
@ -133,7 +133,7 @@ class PDFViewer extends BaseViewer {
}
setSpreadMode(mode) {
if (mode === this.spreadMode) {
if (mode === this._spreadMode) {
return;
}
super.setSpreadMode(mode);
@ -150,12 +150,12 @@ class PDFViewer extends BaseViewer {
// Temporarily remove all the pages from the DOM.
viewer.textContent = '';
if (this.spreadMode === SpreadMode.NONE) {
if (this._spreadMode === SpreadMode.NONE) {
for (let i = 0, iMax = pages.length; i < iMax; ++i) {
viewer.appendChild(pages[i].div);
}
} else {
const parity = this.spreadMode - 1;
const parity = this._spreadMode - 1;
let spread = null;
for (let i = 0, iMax = pages.length; i < iMax; ++i) {
if (spread === null) {