diff --git a/web/app_options.js b/web/app_options.js index 4d0a479d1..d0cafe242 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -70,8 +70,7 @@ const defaultOptions = { }, defaultZoomDelay: { /** @type {number} */ - value: - typeof PDFJSDev === "undefined" || !PDFJSDev.test("GENERIC") ? 400 : -1, + value: 400, kind: OptionKind.VIEWER + OptionKind.PREFERENCE, }, defaultZoomValue: { diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index fc54bc847..788b78dd4 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -230,20 +230,13 @@ class PDFViewer { ); } this.container = options.container; - this.#resizeObserver.observe(this.container); - this.viewer = options.viewer || options.container.firstElementChild; if ( typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || GENERIC") ) { - if ( - !( - this.container?.tagName.toUpperCase() === "DIV" && - this.viewer?.tagName.toUpperCase() === "DIV" - ) - ) { + if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") { throw new Error("Invalid `container` and/or `viewer` option."); } @@ -254,6 +247,8 @@ class PDFViewer { throw new Error("The `container` must be absolutely positioned."); } } + this.#resizeObserver.observe(this.container); + this.eventBus = options.eventBus; this.linkService = options.linkService || new SimpleLinkService(); this.downloadManager = options.downloadManager || null; @@ -2001,6 +1996,9 @@ class PDFViewer { * @param {Object|null} [options] */ increaseScale(steps = 1, options = null) { + if (!this.pdfDocument) { + return; + } let newScale = this._currentScale; do { newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2); @@ -2019,6 +2017,9 @@ class PDFViewer { * @param {Object|null} [options] */ decreaseScale(steps = 1, options = null) { + if (!this.pdfDocument) { + return; + } let newScale = this._currentScale; do { newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);