Merge pull request #13874 from Snuffleupagus/components-annotation-zoom-factor

Update the Annotation `--zoom-factor` CSS variable when `PDFPageView` is used standalone (PR 13868 follow-up)
This commit is contained in:
Tim van der Meij 2021-08-05 22:28:51 +02:00 committed by GitHub
commit 849bab973c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -202,7 +202,6 @@ class BaseViewer {
} else {
this.renderingQueue = options.renderingQueue;
}
this._doc = document.documentElement;
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this));
@ -708,7 +707,6 @@ class BaseViewer {
}
return;
}
this._doc.style.setProperty("--zoom-factor", newScale);
for (let i = 0, ii = this._pages.length; i < ii; i++) {

View File

@ -110,6 +110,7 @@ class PDFPageView {
this.renderingState = RenderingStates.INITIAL;
this.resume = null;
this._renderError = null;
this._isStandalone = !this.renderingQueue?.hasViewer();
this.annotationLayer = null;
this.textLayer = null;
@ -281,6 +282,10 @@ class PDFPageView {
if (optionalContentConfigPromise instanceof Promise) {
this._optionalContentConfigPromise = optionalContentConfigPromise;
}
if (this._isStandalone) {
const doc = document.documentElement;
doc.style.setProperty("--zoom-factor", this.scale);
}
const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
this.viewport = this.viewport.clone({

View File

@ -60,6 +60,13 @@ class PDFRenderingQueue {
return this.highestPriorityPage === view.renderingId;
}
/**
* @returns {boolean}
*/
hasViewer() {
return !!this.pdfViewer;
}
/**
* @param {Object} currentlyVisiblePages
*/