Merge pull request #15930 from calixteman/15929

Move --scale-factor variable in the viewer container (fix #15929)
This commit is contained in:
calixteman 2023-01-17 16:37:49 +01:00 committed by GitHub
commit e65f1767ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -36,7 +36,6 @@ import {
import { import {
approximateFraction, approximateFraction,
DEFAULT_SCALE, DEFAULT_SCALE,
docStyle,
OutputScale, OutputScale,
RendererType, RendererType,
RenderingStates, RenderingStates,
@ -206,7 +205,7 @@ class PDFPageView {
) { ) {
// Ensure that the various layers always get the correct initial size, // Ensure that the various layers always get the correct initial size,
// see issue 15795. // see issue 15795.
docStyle.setProperty( container?.style.setProperty(
"--scale-factor", "--scale-factor",
this.scale * PixelsPerInch.PDF_TO_CSS_UNITS this.scale * PixelsPerInch.PDF_TO_CSS_UNITS
); );
@ -562,7 +561,10 @@ class PDFPageView {
PDFJSDev.test("!PRODUCTION || GENERIC")) && PDFJSDev.test("!PRODUCTION || GENERIC")) &&
this._isStandalone this._isStandalone
) { ) {
docStyle.setProperty("--scale-factor", this.viewport.scale); this.div.parentNode?.style.setProperty(
"--scale-factor",
this.viewport.scale
);
} }
if ( if (

View File

@ -23,7 +23,6 @@
--page-margin: 1px auto -8px; --page-margin: 1px auto -8px;
--page-border: 9px solid transparent; --page-border: 9px solid transparent;
--spreadHorizontalWrapped-margin-LR: -3.5px; --spreadHorizontalWrapped-margin-LR: -3.5px;
--scale-factor: 1;
--loading-icon-delay: 400ms; --loading-icon-delay: 400ms;
} }
@ -47,6 +46,10 @@
} }
.pdfViewer { .pdfViewer {
/* Define this variable here and not in :root to avoid to reflow all the UI
when scaling (see #15929). */
--scale-factor: 1;
padding-bottom: var(--pdfViewer-padding-bottom); padding-bottom: var(--pdfViewer-padding-bottom);
} }

View File

@ -758,7 +758,7 @@ class PDFViewer {
}); });
// Ensure that the various layers always get the correct initial size, // Ensure that the various layers always get the correct initial size,
// see issue 15795. // see issue 15795.
docStyle.setProperty("--scale-factor", viewport.scale); this.viewer.style.setProperty("--scale-factor", viewport.scale);
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) { for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
const pageView = new PDFPageView({ const pageView = new PDFPageView({
@ -1093,7 +1093,7 @@ class PDFViewer {
return; return;
} }
docStyle.setProperty( this.viewer.style.setProperty(
"--scale-factor", "--scale-factor",
newScale * PixelsPerInch.PDF_TO_CSS_UNITS newScale * PixelsPerInch.PDF_TO_CSS_UNITS
); );