Skip to content

Commit 53d8fa0

Browse files
Resolve animation lifecycle, hydration mismatch, and rendering stability issues in FeatureCard (JhaSourav07#2162)
* fix: GSAP-animation-SSR-hydration-mismatch * fix: formatting issues * fix: GSAP error * fix: useEffect error * fix: format error * fix: formatting errors * fix: formatting errors --------- Co-authored-by: Sourav Jha <souravkjha2007@gmail.com>
1 parent 2da01d1 commit 53d8fa0

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

app/page.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use client';
22
import { trackUser } from '@/utils/tracking';
3-
import InteractiveViewer from '@/components/InteractiveViewer';
43
import Link from 'next/link';
54
import { useRef, useState, useEffect } from 'react';
65
import { AnimatePresence, motion } from 'framer-motion';

components/FeatureCards.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { useRef, useState, useEffect, type ReactNode } from 'react';
44
import gsap from 'gsap';
55
import { ScrollTrigger } from 'gsap/ScrollTrigger';
66

7-
if (typeof window !== 'undefined') {
8-
gsap.registerPlugin(ScrollTrigger);
9-
}
7+
let gsapRegistered = false;
108

119
/* ─── Types ─── */
1210
interface FeatureCardProps {
@@ -44,7 +42,7 @@ function FloatingParticle({
4442
tl.to(ref.current, {
4543
opacity: 0.6,
4644
y: -60,
47-
x: `random(-30, 30)`,
45+
x: Math.random() * 60 - 30,
4846
duration: duration * 0.4,
4947
ease: 'power2.out',
5048
})
@@ -119,8 +117,6 @@ function AnimatedBorder({ color, isHovered }: { color: string; isHovered: boolea
119117
style={{
120118
opacity: 0,
121119
background: `conic-gradient(from 0deg, transparent, ${color}, transparent, ${color}44, transparent)`,
122-
mask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
123-
maskComposite: 'exclude',
124120
WebkitMaskComposite: 'xor',
125121
padding: '1.5px',
126122
}}
@@ -417,6 +413,13 @@ export function FeatureCard({ icon, title, desc, accent, index, accentColor }: F
417413

418414
/* ─── Section Wrapper (optional heading + background glow) ─── */
419415
export function FeatureCardsSection({ children }: { children: ReactNode }) {
416+
useEffect(() => {
417+
if (!gsapRegistered) {
418+
gsap.registerPlugin(ScrollTrigger);
419+
gsapRegistered = true;
420+
}
421+
}, []);
422+
420423
const sectionRef = useRef<HTMLDivElement>(null);
421424
const headingRef = useRef<HTMLHeadingElement>(null);
422425

0 commit comments

Comments
 (0)