Skip to content

Commit

Permalink
Resize div if no height, relates to ivmartel#1655
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Apr 18, 2024
1 parent f750eaa commit 63fd64f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/gui/layerGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,14 @@ export class LayerGroup {
if (typeof maxSize === 'undefined') {
return undefined;
}
// if the container has a width but no height,
// resize it to follow the same ratio to completely
// fill the div with the image
if (this.#containerDiv.offsetHeight === 0) {
const ratioX = this.#containerDiv.offsetWidth / maxSize.x;
const height = maxSize.y * ratioX;
this.#containerDiv.style.height = height + 'px';
}
// return best fit
return Math.min(
this.#containerDiv.offsetWidth / maxSize.x,
Expand Down

0 comments on commit 63fd64f

Please sign in to comment.