Skip to content

Replace the --viewport-scale-factor CSS variable #14780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2726,8 +2726,9 @@ class CanvasGraphics {
canvasHeight
);
const { canvas, context } = this.annotationCanvas;
canvas.style.width = `calc(${width}px * var(--viewport-scale-factor))`;
canvas.style.height = `calc(${height}px * var(--viewport-scale-factor))`;
const viewportScaleFactorStr = `var(--zoom-factor) * ${PixelsPerInch.PDF_TO_CSS_UNITS}`;
canvas.style.width = `calc(${width}px * ${viewportScaleFactorStr})`;
canvas.style.height = `calc(${height}px * ${viewportScaleFactorStr})`;
this.annotationCanvasMap.set(id, canvas);
this.annotationCanvas.savedCtx = this.ctx;
this.ctx = context;
Expand Down
4 changes: 0 additions & 4 deletions web/base_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1012,10 +1012,6 @@ class BaseViewer {
}

this._doc.style.setProperty("--zoom-factor", newScale);
this._doc.style.setProperty(
"--viewport-scale-factor",
newScale * PixelsPerInch.PDF_TO_CSS_UNITS
);

const updateArgs = { scale: newScale };
for (const pageView of this._pages) {
Expand Down
4 changes: 1 addition & 3 deletions web/pdf_page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,14 @@ class PDFPageView {
}

const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
const viewportScale = this.scale * PixelsPerInch.PDF_TO_CSS_UNITS;
this.viewport = this.viewport.clone({
scale: viewportScale,
scale: this.scale * PixelsPerInch.PDF_TO_CSS_UNITS,
rotation: totalRotation,
});

if (this._isStandalone) {
const { style } = document.documentElement;
style.setProperty("--zoom-factor", this.scale);
style.setProperty("--viewport-scale-factor", viewportScale);
}

if (this.svg) {
Expand Down
1 change: 0 additions & 1 deletion web/pdf_viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
--page-border: 9px solid transparent;
--spreadHorizontalWrapped-margin-LR: -3.5px;
--zoom-factor: 1;
--viewport-scale-factor: 1;
}

@media screen and (forced-colors: active) {
Expand Down