mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-22 09:15:33 +03:00
Handle tiny images & fix layout
Honestly there's just too many possibilities
This commit is contained in:
parent
17a3939061
commit
c0c7fdd6e1
2 changed files with 37 additions and 19 deletions
|
@ -362,21 +362,29 @@ function Media({
|
|||
naturalWidth &&
|
||||
naturalHeight
|
||||
) {
|
||||
const naturalAspectRatio = (
|
||||
naturalWidth / naturalHeight
|
||||
).toFixed(2);
|
||||
const displayAspectRatio = (
|
||||
clientWidth / clientHeight
|
||||
).toFixed(2);
|
||||
const similarThreshold = 0.05;
|
||||
const minDimension = 88;
|
||||
if (
|
||||
naturalAspectRatio === displayAspectRatio ||
|
||||
Math.abs(naturalAspectRatio - displayAspectRatio) <
|
||||
similarThreshold
|
||||
naturalWidth < minDimension ||
|
||||
naturalHeight < minDimension
|
||||
) {
|
||||
$media.dataset.hasNaturalAspectRatio = true;
|
||||
$media.dataset.hasSmallDimension = true;
|
||||
} else {
|
||||
const naturalAspectRatio = (
|
||||
naturalWidth / naturalHeight
|
||||
).toFixed(2);
|
||||
const displayAspectRatio = (
|
||||
clientWidth / clientHeight
|
||||
).toFixed(2);
|
||||
const similarThreshold = 0.05;
|
||||
if (
|
||||
naturalAspectRatio === displayAspectRatio ||
|
||||
Math.abs(naturalAspectRatio - displayAspectRatio) <
|
||||
similarThreshold
|
||||
) {
|
||||
$media.dataset.hasNaturalAspectRatio = true;
|
||||
}
|
||||
// $media.dataset.aspectRatios = `${naturalAspectRatio} ${displayAspectRatio}`;
|
||||
}
|
||||
// $media.dataset.aspectRatios = `${naturalAspectRatio} ${displayAspectRatio}`;
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
|
|
@ -1074,6 +1074,11 @@
|
|||
&[data-has-natural-aspect-ratio] {
|
||||
--media-radius: 4px;
|
||||
}
|
||||
|
||||
&[data-has-small-dimension] img {
|
||||
object-fit: contain;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
}
|
||||
.status .media-container.media-eq1 .media[data-orientation='portrait'] {
|
||||
/* width: auto;
|
||||
|
@ -1349,22 +1354,27 @@ body:has(#modal-container .carousel) .status .media img:hover {
|
|||
background-color: var(--outline-color);
|
||||
}
|
||||
|
||||
.status.large .media-large-container {
|
||||
.status .media-large-container {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: row;
|
||||
/* align-items: center;
|
||||
justify-content: center; */
|
||||
column-gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
text-align: center;
|
||||
|
||||
.media[data-has-small-dimension] {
|
||||
width: auto !important;
|
||||
}
|
||||
|
||||
figure {
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
|
||||
figcaption {
|
||||
text-align: center;
|
||||
flex-grow: 0 !important;
|
||||
flex-basis: auto !important;
|
||||
align-self: flex-start !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue