Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Constrain width of media in large mode
Browse files Browse the repository at this point in the history
  • Loading branch information
robintown committed Mar 22, 2022
1 parent b706551 commit 288dc2c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/settings/enums/ImageSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function suggestedSize(size: ImageSize, contentSize: Dimensions, maxHeigh
h: maxHeight ? Math.min(maxSize.h, contentSize.h, maxHeight) : Math.min(maxSize.h, contentSize.h),
};

if (constrainedSize.h * aspectRatio < constrainedSize.w || size === ImageSize.Large) {
if (constrainedSize.h * aspectRatio < constrainedSize.w) {
// Height dictates width
return { w: constrainedSize.h * aspectRatio, h: constrainedSize.h };
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/settings/enums/ImageSize-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ describe("ImageSize", () => {
const size = suggestedSize(ImageSize.Normal, { w: 162, h: 648 });
expect(size).toStrictEqual({ w: 81, h: 324 });
});
it("does not constrain width in large mode", () => {
it("constrains width in large mode", () => {
const size = suggestedSize(ImageSize.Large, { w: 2400, h: 1200 });
expect(size).toStrictEqual({ w: 1200, h: 600 });
expect(size).toStrictEqual({ w: 800, h: 400 });
});
it("returns max values if content size is not specified", () => {
const size = suggestedSize(ImageSize.Normal, { w: null, h: null });
Expand Down

0 comments on commit 288dc2c

Please sign in to comment.