From 0928d26d542f4fb1ecc1caf195224eceec928e5f Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 17 Feb 2022 22:28:03 +0100 Subject: [PATCH] Replace the `scaled` property, in the `getOutputScale` return, with a getter In some cases, in the `PDFPageView` implementation, we're modifying the `sx`/`sy` properties when CSS-only zooming is being used. Currently this requires that you remember to *manually* update the `scaled` property to prevent issues, which doesn't feel all that nice and also seems error-prone. By replacing the `scaled` property with a getter, this is now handled automatically instead. --- web/pdf_page_view.js | 2 -- web/ui_utils.js | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 1bb4f1bc8..5777d1042 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -816,7 +816,6 @@ class PDFPageView { // of the page. outputScale.sx *= actualSizeViewport.width / viewport.width; outputScale.sy *= actualSizeViewport.height / viewport.height; - outputScale.scaled = true; } if (this.maxCanvasPixels > 0) { @@ -825,7 +824,6 @@ class PDFPageView { if (outputScale.sx > maxScale || outputScale.sy > maxScale) { outputScale.sx = maxScale; outputScale.sy = maxScale; - outputScale.scaled = true; this.hasRestrictedScaling = true; } else { this.hasRestrictedScaling = false; diff --git a/web/ui_utils.js b/web/ui_utils.js index 64450b372..e3479d500 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -87,7 +87,10 @@ function getOutputScale() { return { sx: pixelRatio, sy: pixelRatio, - scaled: pixelRatio !== 1, + + get scaled() { + return this.sx !== 1 || this.sy !== 1; + }, }; }