Skip to content

Commit

Permalink
Merge pull request #15069 from Snuffleupagus/annotationLayer-dimensions
Browse files Browse the repository at this point in the history
Ensure that the annotationLayer has the correct dimensions (PR 15036 follow-up)
  • Loading branch information
Snuffleupagus authored Jun 21, 2022
2 parents 6ee538e + 7cce3fb commit db6f675
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit db6f675

Please sign in to comment.