mirror of https://github.com/tooot-app/app
Fix too thin images
This commit is contained in:
parent
b52b529550
commit
34c0bbf4bb
|
@ -9,7 +9,12 @@ export const aspectRatio = ({
|
||||||
width?: number
|
width?: number
|
||||||
height?: number
|
height?: number
|
||||||
}): number => {
|
}): number => {
|
||||||
const cropTooTall = (height || 1) / (width || 1) > 3 / 2 ? 2 / 3 : (width || 1) / (height || 1)
|
const defaultCrop =
|
||||||
|
(height || 1) / (width || 1) > 3 / 2
|
||||||
|
? 2 / 3
|
||||||
|
: (width || 1) / (height || 1) > 4
|
||||||
|
? 4
|
||||||
|
: (width || 1) / (height || 1)
|
||||||
|
|
||||||
const isEven = total % 2 == 0
|
const isEven = total % 2 == 0
|
||||||
if (total > 5) {
|
if (total > 5) {
|
||||||
|
@ -26,12 +31,12 @@ export const aspectRatio = ({
|
||||||
} else {
|
} else {
|
||||||
switch (isEven) {
|
switch (isEven) {
|
||||||
case true:
|
case true:
|
||||||
return cropTooTall
|
return defaultCrop
|
||||||
case false:
|
case false:
|
||||||
if ((index || -2) + 1 == total) {
|
if ((index || -2) + 1 == total) {
|
||||||
return cropTooTall * 2
|
return defaultCrop * 2
|
||||||
} else {
|
} else {
|
||||||
return cropTooTall
|
return defaultCrop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue