mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Fix reaction animations
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
animation: messageReactionsFadeIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.reaction-button {
|
.reaction-button {
|
||||||
@@ -221,6 +222,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Animation for reactions appearing/disappearing
|
// Animation for reactions appearing/disappearing
|
||||||
|
@keyframes messageReactionsFadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes reactionFadeIn {
|
@keyframes reactionFadeIn {
|
||||||
from {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|||||||
@@ -12,21 +12,32 @@ export function MessageReactions({ reactions, onReactionClick, messageId }: Mess
|
|||||||
const { user } = useAppState();
|
const { user } = useAppState();
|
||||||
const [visibleReactions, setVisibleReactions] = useState<Reaction[]>([]);
|
const [visibleReactions, setVisibleReactions] = useState<Reaction[]>([]);
|
||||||
const [animatingReactions, setAnimatingReactions] = useState<Set<string>>(new Set());
|
const [animatingReactions, setAnimatingReactions] = useState<Set<string>>(new Set());
|
||||||
|
const [isVisible, setIsVisible] = useState(false);
|
||||||
|
|
||||||
// Handle reactions with animation
|
// Handle reactions with animation
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!reactions || reactions.length === 0) {
|
if (!reactions || reactions.length === 0) {
|
||||||
// Animate out all visible reactions
|
// If we have visible reactions, animate them out
|
||||||
|
if (visibleReactions.length > 0) {
|
||||||
visibleReactions.forEach(reaction => {
|
visibleReactions.forEach(reaction => {
|
||||||
setAnimatingReactions(prev => new Set(prev).add(reaction.emoji));
|
setAnimatingReactions(prev => new Set(prev).add(reaction.emoji));
|
||||||
|
});
|
||||||
|
// After animation completes, hide the component
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setVisibleReactions([]);
|
setVisibleReactions([]);
|
||||||
setAnimatingReactions(new Set());
|
setAnimatingReactions(new Set());
|
||||||
|
setIsVisible(false);
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
} else {
|
||||||
|
// No visible reactions, hide immediately
|
||||||
|
setIsVisible(false);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show the component when we have reactions
|
||||||
|
setIsVisible(true);
|
||||||
|
|
||||||
// Deduplicate reactions by emoji (safety measure)
|
// Deduplicate reactions by emoji (safety measure)
|
||||||
const uniqueReactions = reactions.reduce((acc, reaction) => {
|
const uniqueReactions = reactions.reduce((acc, reaction) => {
|
||||||
const existing = acc.find(r => r.emoji === reaction.emoji);
|
const existing = acc.find(r => r.emoji === reaction.emoji);
|
||||||
@@ -78,7 +89,8 @@ export function MessageReactions({ reactions, onReactionClick, messageId }: Mess
|
|||||||
});
|
});
|
||||||
}, [reactions]);
|
}, [reactions]);
|
||||||
|
|
||||||
if (!reactions || reactions.length === 0) {
|
// Don't render if not visible
|
||||||
|
if (!isVisible) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user