bigbuffet-rw/app/soapbox/utils/media-aspect-ratio.ts

18 lines
485 B
TypeScript
Raw Normal View History

2021-05-30 11:43:09 -07:00
export const minimumAspectRatio = 9 / 16; // Portrait phone
export const maximumAspectRatio = 10; // Generous min-height
2020-03-27 13:59:38 -07:00
export const isPanoramic = (ar: number) => {
2020-03-27 13:59:38 -07:00
if (isNaN(ar)) return false;
return ar >= maximumAspectRatio;
2020-04-14 11:44:40 -07:00
};
2020-03-27 13:59:38 -07:00
export const isPortrait = (ar: number) => {
2020-03-27 13:59:38 -07:00
if (isNaN(ar)) return false;
return ar <= minimumAspectRatio;
2020-04-14 11:44:40 -07:00
};
2020-03-27 13:59:38 -07:00
export const isNonConformingRatio = (ar: number) => {
2020-03-27 13:59:38 -07:00
if (isNaN(ar)) return false;
return !isPanoramic(ar) && !isPortrait(ar);
2020-04-14 11:44:40 -07:00
};