Move --scale-factor variable in the viewer container (fix #15929)

When a css variable is update in a node then all the children under this
node are updated.
In order to avoid to update all the UI when a page is rescaling, this
patch moves the --scale-factor from the :root to the viewer container.
This commit is contained in:
Calixte Denizet 2023-01-16 19:38:33 +01:00
parent e9c8aa63e3
commit 089ed6fb65
3 changed files with 11 additions and 6 deletions

View file

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