Merge pull request #15069 from Snuffleupagus/annotationLayer-dimensions

Ensure that the annotationLayer has the correct dimensions (PR 15036 follow-up)
This commit is contained in:
Jonas Jenwald 2022-06-21 15:57:21 +02:00 committed by GitHub
commit db6f675baa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2505,18 +2505,19 @@ class AnnotationLayer {
div.hidden = false;
}
static setDimensions(div, viewport) {
const { width, height, rotation } = viewport;
/**
* @param {HTMLDivElement} div
* @param {PageViewport} viewport
*/
static setDimensions(div, { width, height, rotation }) {
const { style } = div;
if (rotation === 0 || rotation === 180) {
style.width = `${width}px`;
style.height = `${height}px`;
} else {
style.width = `${height}px`;
style.height = `${width}px`;
}
const flipOrientation = rotation % 180 !== 0,
widthStr = Math.floor(width) + "px",
heightStr = Math.floor(height) + "px";
style.width = flipOrientation ? heightStr : widthStr;
style.height = flipOrientation ? widthStr : heightStr;
div.setAttribute("data-annotation-rotation", rotation);
}