Fix animation positioning issues

Adjusted the positioning of dots (nodes) in the animation to prevent clustering in a corner and ensured that circles are displayed correctly within the main space of the container.
[skip gpt_engineer]
Этот коммит содержится в:
gpt-engineer-app[bot] 2024-12-15 14:48:28 +00:00
родитель 1ae0567b9f
Коммит 20648a514f

Просмотреть файл

@ -3,18 +3,18 @@ import { motion } from 'framer-motion';
export const CommunityAnimation = ({ className = '' }: { className?: string }) => { export const CommunityAnimation = ({ className = '' }: { className?: string }) => {
const groups = Array.from({ length: 3 }, (_, i) => ({ const groups = Array.from({ length: 3 }, (_, i) => ({
x: 25 + i * 25, // Spread groups evenly (25%, 50%, 75%) x: 25 + i * 25, // Spread groups horizontally (25%, 50%, 75%)
y: 50, // Center vertically y: 50, // Center vertically
members: Array.from({ length: 8 }, (_, j) => ({ members: Array.from({ length: 8 }, (_, j) => ({
id: i * 8 + j, id: i * 8 + j,
initialX: Math.random() * 80 + 10, initialX: Math.random() * 100,
initialY: Math.random() * 80 + 10, initialY: Math.random() * 100,
})) }))
})); }));
return ( return (
<div className={`relative w-full h-40 overflow-hidden bg-black/20 rounded-lg ${className}`}> <div className={`relative w-full h-40 overflow-hidden bg-black/20 rounded-lg ${className}`}>
{/* Background network effect similar to MemeAnimation */} {/* Background network effect */}
<div className="absolute inset-0 w-full opacity-20"> <div className="absolute inset-0 w-full opacity-20">
{[...Array(20)].map((_, i) => ( {[...Array(20)].map((_, i) => (
<div <div
@ -30,46 +30,29 @@ export const CommunityAnimation = ({ className = '' }: { className?: string }) =
))} ))}
</div> </div>
{/* Container for community groups with explicit positioning context */} {/* Container for community groups */}
<div className="absolute inset-0"> <div className="absolute inset-0">
{groups.map((group, groupIndex) => ( {groups.map((group, groupIndex) => (
<React.Fragment key={groupIndex}> <div
{group.members.map((member) => ( key={groupIndex}
<motion.div className="absolute"
key={member.id} style={{
className="absolute w-2 h-2 bg-yellow-500 rounded-full" left: `${group.x}%`,
initial={{ top: `${group.y}%`,
x: `${member.initialX}%`, width: '80px',
y: `${member.initialY}%`, height: '80px',
opacity: 0, transform: 'translate(-50%, -50%)'
scale: 0.5, }}
}} >
animate={{ {/* Circle container for each group */}
x: `${group.x}%`,
y: `${group.y}%`,
opacity: 1,
scale: 1,
}}
transition={{
duration: 2,
delay: member.id * 0.1,
ease: "easeOut",
}}
style={{
position: 'absolute',
transform: 'translate(-50%, -50%)',
}}
/>
))}
<motion.div <motion.div
className="absolute rounded-full border-2 border-yellow-500/30" className="absolute rounded-full border-2 border-yellow-500/30"
style={{ style={{
width: '25%', width: '100%',
height: '50%', height: '100%',
left: `${group.x}%`, left: '50%',
top: `${group.y}%`, top: '50%',
transform: 'translate(-50%, -50%)', transform: 'translate(-50%, -50%)'
}} }}
initial={{ initial={{
scale: 0, scale: 0,
@ -87,7 +70,36 @@ export const CommunityAnimation = ({ className = '' }: { className?: string }) =
ease: "easeOut", ease: "easeOut",
}} }}
/> />
</React.Fragment>
{/* Dots for each member */}
{group.members.map((member) => (
<motion.div
key={member.id}
className="absolute w-2 h-2 bg-yellow-500 rounded-full"
style={{
left: '50%',
top: '50%',
}}
initial={{
x: `${member.initialX - 50}%`,
y: `${member.initialY - 50}%`,
opacity: 0,
scale: 0.5,
}}
animate={{
x: `${(Math.cos(member.id) * 30)}%`,
y: `${(Math.sin(member.id) * 30)}%`,
opacity: 1,
scale: 1,
}}
transition={{
duration: 2,
delay: member.id * 0.1,
ease: "easeOut",
}}
/>
))}
</div>
))} ))}
</div> </div>
</div> </div>