Another aspect ratio style fix

This commit is contained in:
Lim Chee Aun 2023-08-02 17:41:00 +08:00
parent 88accb2a78
commit 1887a34fc5
2 changed files with 15 additions and 6 deletions

View file

@ -116,12 +116,16 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
if (smaller) setImageSmallerThanParent(smaller);
}, [width, height]);
const maxAspectHeight = window.innerHeight * 0.33;
const maxAspectHeight =
window.innerHeight * (orientation === 'portrait' ? 0.45 : 0.33);
const maxHeight = orientation === 'portrait' ? 0 : 160;
const mediaStyles = {
'--width': `${width}px`,
'--height': `${height}px`,
// Calculate '--aspectWidth' based on aspect ratio calculated from '--width' and '--height', max height has to be 160px
'--aspectWidth': `${(width / height) * Math.max(160, maxAspectHeight)}px`,
'--aspectWidth': `${
(width / height) * Math.max(maxHeight, maxAspectHeight)
}px`,
aspectRatio: `${width} / ${height}`,
};

View file

@ -618,16 +618,21 @@
max-height: min(var(--height), 33vh);
}
.status .media-container.media-eq1 .media[data-orientation='portrait'] {
width: auto;
/* width: auto;
height: min(var(--height), 45vh);
max-height: none;
max-height: none; */
max-height: min(var(--height), 45vh);
}
.status.large .media-container.media-eq1 {
max-height: min(var(--height), 60vh);
}
.status.large .media-container.media-eq1 .media[data-orientation='portrait'] {
height: min(var(--height), 60vh);
.status.large .media-container.media-eq1 .media {
width: min(var(--width), 100%);
max-height: min(var(--height), 80vh);
}
/* .status.large .media-container.media-eq1 .media[data-orientation='portrait'] {
height: min(var(--height), 60vh);
} */
.status-carousel .status .media-container.media-eq1 .media {
width: min(var(--width), 100%);
height: auto;