Skip to content

Commit 0671685

Browse files
committed
Fixed calculations of pixels
1 parent 3732d47 commit 0671685

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/js/media-preview-thumbnail.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,8 @@ class MediaPreviewThumbnail extends globalThis.HTMLElement {
168168
const minRatioX = parseInt(minWidth) / w;
169169
const minRatioY = parseInt(minHeight) / h;
170170

171-
const isScalingDownX = maxRatioX < 1;
172-
const isScalingDownY = maxRatioY < 1;
173-
174-
scaleX = isScalingDownX ? maxRatioX : minRatioX > 1 ? minRatioX : 1;
175-
scaleY = isScalingDownY ? maxRatioY : minRatioY > 1 ? minRatioY : 1;
171+
scaleX = maxRatioX < 1 ? maxRatioX : Math.max(maxRatioX, minRatioX);
172+
scaleY = maxRatioY < 1 ? maxRatioY : Math.max(maxRatioY, minRatioY);
176173
} else {
177174
const maxRatio = Math.min(parseInt(maxWidth) / w, parseInt(maxHeight) / h);
178175
const minRatio = Math.max(parseInt(minWidth) / w, parseInt(minHeight) / h);

0 commit comments

Comments
 (0)