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.
This commit is contained in:
Jonas Jenwald 2022-02-17 22:28:03 +01:00
parent 0159ec0a12
commit 0928d26d54
2 changed files with 4 additions and 3 deletions

View File

@ -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;

View File

@ -87,7 +87,10 @@ function getOutputScale() {
return {
sx: pixelRatio,
sy: pixelRatio,
scaled: pixelRatio !== 1,
get scaled() {
return this.sx !== 1 || this.sy !== 1;
},
};
}