Similar Channels: Fix animation (#6778)
This commit is contained in:
parent
214e8a3c75
commit
88b6d3a6d7
@ -61,6 +61,12 @@
|
|||||||
background: var(--color-background);
|
background: var(--color-background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channelsWrapper {
|
||||||
|
transform: scale(0) translateY(-50%);
|
||||||
|
height: 0;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.is-appearing {
|
.is-appearing {
|
||||||
animation: 0.15s ease-out channels-appear forwards;
|
animation: 0.15s ease-out channels-appear forwards;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,6 +67,13 @@ const SimilarChannels = ({
|
|||||||
const ref = useRef<HTMLDivElement>();
|
const ref = useRef<HTMLDivElement>();
|
||||||
|
|
||||||
const ignoreAutoScrollRef = useRef(false);
|
const ignoreAutoScrollRef = useRef(false);
|
||||||
|
const wasExpandedRef = useRef(false);
|
||||||
|
const wasClosedManuallyRef = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
wasClosedManuallyRef.current = false;
|
||||||
|
}, [chatId]);
|
||||||
|
|
||||||
const similarChannels = useMemo(() => {
|
const similarChannels = useMemo(() => {
|
||||||
if (!similarChannelIds) {
|
if (!similarChannelIds) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@ -111,6 +118,7 @@ const SimilarChannels = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isExpanded) {
|
if (isExpanded) {
|
||||||
|
wasExpandedRef.current = true;
|
||||||
markShowing();
|
markShowing();
|
||||||
markNotHiding();
|
markNotHiding();
|
||||||
setShouldRenderSkeleton(!similarChannelIds);
|
setShouldRenderSkeleton(!similarChannelIds);
|
||||||
@ -119,18 +127,21 @@ const SimilarChannels = ({
|
|||||||
ref.current?.scrollIntoView({ behavior: 'smooth' });
|
ref.current?.scrollIntoView({ behavior: 'smooth' });
|
||||||
}, ANIMATION_DURATION);
|
}, ANIMATION_DURATION);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (wasExpandedRef.current) {
|
||||||
markNotShowing();
|
markNotShowing();
|
||||||
markHiding();
|
markHiding();
|
||||||
}
|
}
|
||||||
}, [isExpanded, similarChannelIds]);
|
}, [isExpanded, similarChannelIds]);
|
||||||
|
|
||||||
const handleToggle = useLastCallback(() => {
|
const handleToggle = useLastCallback(() => {
|
||||||
|
if (isExpanded) {
|
||||||
|
wasClosedManuallyRef.current = true;
|
||||||
|
}
|
||||||
toggleChannelRecommendations({ chatId });
|
toggleChannelRecommendations({ chatId });
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!channelJoinInfo?.joinedDate || isExpanded) return;
|
if (!channelJoinInfo?.joinedDate || isExpanded || wasClosedManuallyRef.current) return;
|
||||||
if (getServerTime() - channelJoinInfo.joinedDate <= AUTO_EXPAND_TIME) {
|
if (getServerTime() - channelJoinInfo.joinedDate <= AUTO_EXPAND_TIME) {
|
||||||
handleToggle();
|
handleToggle();
|
||||||
ignoreAutoScrollRef.current = true;
|
ignoreAutoScrollRef.current = true;
|
||||||
@ -147,6 +158,7 @@ const SimilarChannels = ({
|
|||||||
{shouldRenderChannels && (
|
{shouldRenderChannels && (
|
||||||
<div
|
<div
|
||||||
className={buildClassName(
|
className={buildClassName(
|
||||||
|
styles.channelsWrapper,
|
||||||
isShowing && styles.isAppearing,
|
isShowing && styles.isAppearing,
|
||||||
isHiding && styles.isHiding,
|
isHiding && styles.isHiding,
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user