diff --git a/src/assets/fonts/icomoon.woff b/src/assets/fonts/icomoon.woff index aa7251477..a49cbe1b7 100644 Binary files a/src/assets/fonts/icomoon.woff and b/src/assets/fonts/icomoon.woff differ diff --git a/src/assets/fonts/icomoon.woff2 b/src/assets/fonts/icomoon.woff2 index 7b75d5898..6691b5768 100644 Binary files a/src/assets/fonts/icomoon.woff2 and b/src/assets/fonts/icomoon.woff2 differ diff --git a/src/components/mediaViewer/MediaViewer.tsx b/src/components/mediaViewer/MediaViewer.tsx index daa3260b2..50cf46c2a 100644 --- a/src/components/mediaViewer/MediaViewer.tsx +++ b/src/components/mediaViewer/MediaViewer.tsx @@ -37,6 +37,7 @@ import { renderMessageText } from '../common/helpers/renderMessageText'; import useFlag from '../../hooks/useFlag'; import useForceUpdate from '../../hooks/useForceUpdate'; import { dispatchHeavyAnimationEvent } from '../../hooks/useHeavyAnimationCheck'; +import { exitPictureInPictureIfNeeded } from '../../hooks/usePictureInPicture'; import useLang from '../../hooks/useLang'; import usePrevious from '../../hooks/usePrevious'; import { useMediaProps } from './hooks/useMediaProps'; @@ -62,6 +63,7 @@ type StateProps = { message?: ApiMessage; chatMessages?: Record; collectionIds?: number[]; + isHidden?: boolean; animationLevel: AnimationLevel; shouldSkipHistoryAnimations?: boolean; }; @@ -80,6 +82,7 @@ const MediaViewer: FC = ({ chatMessages, collectionIds, animationLevel, + isHidden, shouldSkipHistoryAnimations, }) => { const { @@ -120,6 +123,7 @@ const MediaViewer: FC = ({ }); const canReport = !!avatarPhoto && !isChatWithSelf; + const isVisible = !isHidden && isOpen; /* Navigation */ const singleMediaId = webPagePhoto || webPageVideo ? mediaId : undefined; @@ -140,6 +144,12 @@ const MediaViewer: FC = ({ animationKey.current = selectedMediaIndex; } + useEffect(() => { + if (isVisible) { + exitPictureInPictureIfNeeded(); + } + }, [isVisible]); + useEffect(() => { if (!IS_SINGLE_COLUMN_LAYOUT) return; document.body.classList.toggle('is-media-viewer-open', isOpen); @@ -164,14 +174,17 @@ const MediaViewer: FC = ({ }, [forceUpdate]); const prevMessage = usePrevious(message); + const prevIsHidden = usePrevious(isHidden); const prevOrigin = usePrevious(origin); + const prevMediaId = usePrevious(mediaId); const prevAvatarOwner = usePrevious(avatarOwner); const prevBestImageData = usePrevious(bestImageData); const textParts = message ? renderMessageText(message) : undefined; const hasFooter = Boolean(textParts); + const shouldAnimateOpening = prevIsHidden && prevMediaId !== mediaId; useEffect(() => { - if (isGhostAnimation && isOpen && !prevMessage && !prevAvatarOwner) { + if (isGhostAnimation && isOpen && (!prevMessage || shouldAnimateOpening) && !prevAvatarOwner) { dispatchHeavyAnimationEvent(ANIMATION_DURATION + ANIMATION_END_DELAY); animateOpening(hasFooter, origin!, bestImageData!, dimensions, isVideo, message); } @@ -181,7 +194,7 @@ const MediaViewer: FC = ({ animateClosing(prevOrigin!, prevBestImageData!, prevMessage || undefined); } }, [ - isGhostAnimation, isOpen, origin, prevOrigin, message, prevMessage, prevAvatarOwner, + isGhostAnimation, isOpen, shouldAnimateOpening, origin, prevOrigin, message, prevMessage, prevAvatarOwner, bestImageData, prevBestImageData, dimensions, isVideo, hasFooter, ]); @@ -269,7 +282,12 @@ const MediaViewer: FC = ({ } return ( - +
{IS_SINGLE_COLUMN_LAYOUT && ( + {isPictureInPictureSupported && ( + + )} {isFullscreenSupported && (