diff --git a/web/base_viewer.js b/web/base_viewer.js index 11f5432aa..d259ef4d3 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -1020,26 +1020,10 @@ class BaseViewer { } setScrollMode(mode) { - if (mode === this.scrollMode) { - return; - } if (!Number.isInteger(mode) || !Object.values(ScrollMode).includes(mode)) { throw new Error(`Invalid scroll mode: ${mode}`); } - this.scrollMode = mode; - this._updateScrollModeClasses(); - this.eventBus.dispatch('scrollmodechanged', { mode, }); - - const pageNumber = this._currentPageNumber; - // Non-numeric scale modes can be sensitive to the scroll orientation. - // Call this before re-scrolling to the current page, to ensure that any - // changes in scale don't move the current page. - if (isNaN(this._currentScaleValue)) { - this._setScale(this._currentScaleValue, this.isInPresentationMode); - } - this.scrollPageIntoView({ pageNumber, }); - this.update(); } _updateScrollModeClasses() { @@ -1047,16 +1031,10 @@ class BaseViewer { } setSpreadMode(mode) { - if (mode === this.spreadMode) { - return; - } if (!Number.isInteger(mode) || !Object.values(SpreadMode).includes(mode)) { throw new Error(`Invalid spread mode: ${mode}`); } - this.spreadMode = mode; - this.eventBus.dispatch('spreadmodechanged', { mode, }); - this._regroupSpreads(); } _regroupSpreads() { diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 79c3e055b..10d11a4c6 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -87,6 +87,26 @@ class PDFViewer extends BaseViewer { }); } + setScrollMode(mode) { + if (mode === this.scrollMode) { + return; + } + super.setScrollMode(mode); + + this.eventBus.dispatch('scrollmodechanged', { mode, }); + this._updateScrollModeClasses(); + + const pageNumber = this._currentPageNumber; + // Non-numeric scale modes can be sensitive to the scroll orientation. + // Call this before re-scrolling to the current page, to ensure that any + // changes in scale don't move the current page. + if (isNaN(this._currentScaleValue)) { + this._setScale(this._currentScaleValue, this.isInPresentationMode); + } + this.scrollPageIntoView({ pageNumber, }); + this.update(); + } + _updateScrollModeClasses() { const { scrollMode, viewer, } = this; @@ -102,6 +122,16 @@ class PDFViewer extends BaseViewer { } } + setSpreadMode(mode) { + if (mode === this.spreadMode) { + return; + } + super.setSpreadMode(mode); + + this.eventBus.dispatch('spreadmodechanged', { mode, }); + this._regroupSpreads(); + } + _regroupSpreads() { const viewer = this.viewer, pages = this._pages; // Temporarily remove all the pages from the DOM.