From d668e265b51a64e52720276b52f0b2202dbe1e08 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 22 Oct 2021 02:24:31 +0300 Subject: [PATCH] Message / GIF: Make small gifs larger (#1506) --- src/components/common/helpers/mediaDimensions.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/common/helpers/mediaDimensions.ts b/src/components/common/helpers/mediaDimensions.ts index c5f69a4c..9334b45c 100644 --- a/src/components/common/helpers/mediaDimensions.ts +++ b/src/components/common/helpers/mediaDimensions.ts @@ -10,6 +10,7 @@ import { getPhotoInlineDimensions, getVideoDimensions } from '../../../modules/h export const MEDIA_VIEWER_MEDIA_QUERY = '(max-height: 640px)'; export const REM = parseInt(getComputedStyle(document.documentElement).fontSize, 10); export const ROUND_VIDEO_DIMENSIONS = 240; +export const GIF_MIN_WIDTH = 300; export const AVATAR_FULL_DIMENSIONS = { width: 640, height: 640 }; export const LIKE_STICKER_ID = '1258816259753933'; @@ -99,8 +100,10 @@ function calculateDimensionsForMessageMedia({ const aspectRatio = height / width; const availableWidth = getAvailableWidth(fromOwnMessage, isForwarded, isWebPagePhoto, noAvatars); const availableHeight = getAvailableHeight(isGif, aspectRatio); + const mediaWidth = isGif ? Math.max(GIF_MIN_WIDTH, width) : width; + const mediaHeight = isGif ? height * (mediaWidth / width) : height; - return calculateDimensions(availableWidth, availableHeight, width, height); + return calculateDimensions(availableWidth, availableHeight, mediaWidth, mediaHeight); } export function getMediaViewerAvailableDimensions(withFooter: boolean, isVideo: boolean): ApiDimensions {