Merge pull request #15884 from Snuffleupagus/enable-defaultZoomDelay

Enable the `defaultZoomDelay` option/preference unconditionally, and other (small) improvements
This commit is contained in:
Jonas Jenwald 2023-01-02 15:38:29 +01:00 committed by GitHub
commit 1ba6e9437c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -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: {

View File

@ -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);