mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Use state to set natural aspect ratio instead
And fix all other data attributes
This commit is contained in:
parent
8a1fda5a85
commit
497ede1a3d
1 changed files with 11 additions and 5 deletions
|
@ -248,6 +248,8 @@ function Media({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [hasNaturalAspectRatio, setHasNaturalAspectRatio] = useState(undefined);
|
||||||
|
|
||||||
if (isImage) {
|
if (isImage) {
|
||||||
// Note: type: unknown might not have width/height
|
// Note: type: unknown might not have width/height
|
||||||
quickPinchZoomProps.containerProps.style.display = 'inherit';
|
quickPinchZoomProps.containerProps.style.display = 'inherit';
|
||||||
|
@ -272,7 +274,8 @@ function Media({
|
||||||
class={`media media-image ${className}`}
|
class={`media media-image ${className}`}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
data-orientation={orientation}
|
data-orientation={orientation}
|
||||||
data-has-alt={!showInlineDesc}
|
data-has-alt={!showInlineDesc || undefined}
|
||||||
|
data-has-natural-aspect-ratio={hasNaturalAspectRatio || undefined}
|
||||||
style={
|
style={
|
||||||
showOriginal
|
showOriginal
|
||||||
? {
|
? {
|
||||||
|
@ -381,7 +384,8 @@ function Media({
|
||||||
Math.abs(naturalAspectRatio - displayAspectRatio) <
|
Math.abs(naturalAspectRatio - displayAspectRatio) <
|
||||||
similarThreshold
|
similarThreshold
|
||||||
) {
|
) {
|
||||||
$media.dataset.hasNaturalAspectRatio = true;
|
// $media.dataset.hasNaturalAspectRatio = true;
|
||||||
|
setHasNaturalAspectRatio(true);
|
||||||
}
|
}
|
||||||
// $media.dataset.aspectRatios = `${naturalAspectRatio} ${displayAspectRatio}`;
|
// $media.dataset.aspectRatios = `${naturalAspectRatio} ${displayAspectRatio}`;
|
||||||
}
|
}
|
||||||
|
@ -461,8 +465,10 @@ function Media({
|
||||||
data-formatted-duration={
|
data-formatted-duration={
|
||||||
!showOriginal ? formattedDuration : undefined
|
!showOriginal ? formattedDuration : undefined
|
||||||
}
|
}
|
||||||
data-label={isGIF && !showOriginal && !autoGIFAnimate ? 'GIF' : ''}
|
data-label={
|
||||||
data-has-alt={!showInlineDesc}
|
isGIF && !showOriginal && !autoGIFAnimate ? 'GIF' : undefined
|
||||||
|
}
|
||||||
|
data-has-alt={!showInlineDesc || undefined}
|
||||||
// style={{
|
// style={{
|
||||||
// backgroundColor:
|
// backgroundColor:
|
||||||
// rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
|
// rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
|
||||||
|
@ -635,7 +641,7 @@ function Media({
|
||||||
data-formatted-duration={
|
data-formatted-duration={
|
||||||
!showOriginal ? formattedDuration : undefined
|
!showOriginal ? formattedDuration : undefined
|
||||||
}
|
}
|
||||||
data-has-alt={!showInlineDesc}
|
data-has-alt={!showInlineDesc || undefined}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
style={!showOriginal && mediaStyles}
|
style={!showOriginal && mediaStyles}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue