Media Viewer: Blinks before ghost animation (#2514)

This commit is contained in:
Alexander Zinchuk 2023-02-08 13:48:40 +01:00
parent b9e2c752db
commit d64afd5a4f
2 changed files with 8 additions and 1 deletions

View File

@ -304,6 +304,7 @@ const MediaViewer: FC<StateProps> = ({
id="MediaViewer" id="MediaViewer"
isOpen={isOpen} isOpen={isOpen}
isHidden={isHidden} isHidden={isHidden}
shouldAnimateFirstRender
noCloseTransition={shouldSkipHistoryAnimations} noCloseTransition={shouldSkipHistoryAnimations}
> >
<div className="media-viewer-head" dir={lang.isRtl ? 'rtl' : undefined}> <div className="media-viewer-head" dir={lang.isRtl ? 'rtl' : undefined}>

View File

@ -13,6 +13,7 @@ type OwnProps = {
className?: string; className?: string;
onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void; onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
noCloseTransition?: boolean; noCloseTransition?: boolean;
shouldAnimateFirstRender?: boolean;
children: React.ReactNode; children: React.ReactNode;
}; };
@ -25,6 +26,7 @@ const ShowTransition: FC<OwnProps> = ({
onClick, onClick,
children, children,
noCloseTransition, noCloseTransition,
shouldAnimateFirstRender,
}) => { }) => {
const prevIsOpen = usePrevious(isOpen); const prevIsOpen = usePrevious(isOpen);
const prevChildren = usePrevious(children); const prevChildren = usePrevious(children);
@ -34,7 +36,11 @@ const ShowTransition: FC<OwnProps> = ({
shouldRender, shouldRender,
transitionClassNames, transitionClassNames,
} = useShowTransition( } = useShowTransition(
isOpen && !isHidden, undefined, isFirstRender, isCustom ? false : undefined, noCloseTransition, isOpen && !isHidden,
undefined,
isFirstRender && !shouldAnimateFirstRender,
isCustom ? false : undefined,
noCloseTransition,
); );
if (prevIsOpen && !isOpen) { if (prevIsOpen && !isOpen) {