Skip to content

Commit 849bab9

Browse files
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)
2 parents 8292076 + 561faa7 commit 849bab9

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

web/base_viewer.js

-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ class BaseViewer {
202202
} else {
203203
this.renderingQueue = options.renderingQueue;
204204
}
205-
206205
this._doc = document.documentElement;
207206

208207
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this));
@@ -708,7 +707,6 @@ class BaseViewer {
708707
}
709708
return;
710709
}
711-
712710
this._doc.style.setProperty("--zoom-factor", newScale);
713711

714712
for (let i = 0, ii = this._pages.length; i < ii; i++) {

web/pdf_page_view.js

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class PDFPageView {
110110
this.renderingState = RenderingStates.INITIAL;
111111
this.resume = null;
112112
this._renderError = null;
113+
this._isStandalone = !this.renderingQueue?.hasViewer();
113114

114115
this.annotationLayer = null;
115116
this.textLayer = null;
@@ -281,6 +282,10 @@ class PDFPageView {
281282
if (optionalContentConfigPromise instanceof Promise) {
282283
this._optionalContentConfigPromise = optionalContentConfigPromise;
283284
}
285+
if (this._isStandalone) {
286+
const doc = document.documentElement;
287+
doc.style.setProperty("--zoom-factor", this.scale);
288+
}
284289

285290
const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
286291
this.viewport = this.viewport.clone({

web/pdf_rendering_queue.js

+7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ class PDFRenderingQueue {
6060
return this.highestPriorityPage === view.renderingId;
6161
}
6262

63+
/**
64+
* @returns {boolean}
65+
*/
66+
hasViewer() {
67+
return !!this.pdfViewer;
68+
}
69+
6370
/**
6471
* @param {Object} currentlyVisiblePages
6572
*/

0 commit comments

Comments
 (0)