mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Fix too thin images
This commit is contained in:
@ -9,7 +9,12 @@ export const aspectRatio = ({
|
||||
width?: number
|
||||
height?: 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
|
||||
if (total > 5) {
|
||||
@ -26,12 +31,12 @@ export const aspectRatio = ({
|
||||
} else {
|
||||
switch (isEven) {
|
||||
case true:
|
||||
return cropTooTall
|
||||
return defaultCrop
|
||||
case false:
|
||||
if ((index || -2) + 1 == total) {
|
||||
return cropTooTall * 2
|
||||
return defaultCrop * 2
|
||||
} else {
|
||||
return cropTooTall
|
||||
return defaultCrop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user