clamp gif size (#9610)
This commit is contained in:
@@ -11,6 +11,7 @@ import {msg, Trans} from '@lingui/macro'
|
|||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {HITSLOP_20} from '#/lib/constants'
|
import {HITSLOP_20} from '#/lib/constants'
|
||||||
|
import {clamp} from '#/lib/numbers'
|
||||||
import {type EmbedPlayerParams} from '#/lib/strings/embed-player'
|
import {type EmbedPlayerParams} from '#/lib/strings/embed-player'
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import {useAutoplayDisabled} from '#/state/preferences'
|
import {useAutoplayDisabled} from '#/state/preferences'
|
||||||
@@ -111,6 +112,15 @@ export function GifEmbed({
|
|||||||
playerRef.current?.toggleAsync()
|
playerRef.current?.toggleAsync()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
let aspectRatio = 1
|
||||||
|
if (params.dimensions) {
|
||||||
|
aspectRatio = clamp(
|
||||||
|
params.dimensions.width / params.dimensions.height,
|
||||||
|
0.75,
|
||||||
|
4,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
@@ -118,7 +128,8 @@ export function GifEmbed({
|
|||||||
a.overflow_hidden,
|
a.overflow_hidden,
|
||||||
a.border,
|
a.border,
|
||||||
t.atoms.border_contrast_low,
|
t.atoms.border_contrast_low,
|
||||||
{aspectRatio: params.dimensions!.width / params.dimensions!.height},
|
{backgroundColor: t.palette.black},
|
||||||
|
{aspectRatio},
|
||||||
style,
|
style,
|
||||||
]}>
|
]}>
|
||||||
<View
|
<View
|
||||||
|
|||||||
Reference in New Issue
Block a user