Merge pull request #15884 from Snuffleupagus/enable-defaultZoomDelay
Enable the `defaultZoomDelay` option/preference unconditionally, and other (small) improvements
This commit is contained in:
commit
1ba6e9437c
@ -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: {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user