From 3bfd7b9727c48329f5f67084d2187371f24ee522 Mon Sep 17 00:00:00 2001 From: Ishayu Ghosh Date: Sat, 23 Nov 2024 18:40:19 -0800 Subject: [PATCH 1/2] Fix: Adjusted format of About Us section --- src/Pages/Home/AboutUs.tsx | 57 +++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/src/Pages/Home/AboutUs.tsx b/src/Pages/Home/AboutUs.tsx index f3efa31..ba73f5e 100644 --- a/src/Pages/Home/AboutUs.tsx +++ b/src/Pages/Home/AboutUs.tsx @@ -1,27 +1,44 @@ const AboutUs = () => { return ( -
-
-
-

WHO WE ARE

-

- We share a passion for data, technology, and problem-solving. -

-

We are here to expand the horizons of data science as a community together

+
+
+ {/* WHO WE ARE Section */} +
+
+

WHO WE ARE

+

+ We share a passion for data, technology, and problem-solving. +

+

+ We are here to expand the horizons of data science as a community + together. +

+
+
- -
-
-
-
-
-

WHAT WE DO

-

- Build technical skills, network, and gain practical experience in data science. -

-

We are here to expand the horizons of data science as a community together

+ {/* First Image */} +
+ {/* Second Image */} +
+ {/* WHAT WE DO Section */} +
+
+

WHAT WE DO

+

+ Build technical skills, network, and gain practical experience in + data science. +

+

+ We are here to expand the horizons of data science as a community + together. +

+
+
-
); From 6ce5135687ca2791508427951306da7908f2bc96 Mon Sep 17 00:00:00 2001 From: Ishayu Ghosh Date: Sat, 23 Nov 2024 18:45:33 -0800 Subject: [PATCH 2/2] Fix: About Us format & stats count up --- src/Pages/Home/Stats.tsx | 118 ++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 46 deletions(-) diff --git a/src/Pages/Home/Stats.tsx b/src/Pages/Home/Stats.tsx index 1e1769c..1b5ece1 100644 --- a/src/Pages/Home/Stats.tsx +++ b/src/Pages/Home/Stats.tsx @@ -11,73 +11,95 @@ const Stats = () => { const maxNumbers = [500, 78, 35, 28]; - const [statsData, setStatsData] = useState([0, 0, 0, 0]); - const sectionRef = useRef(null); + const [statsData, setStatsData] = useState([0, 0, 0, 0]); + const [animated, setAnimated] = useState([ + false, + false, + false, + false, + ]); + const itemRefs = useRef<(HTMLDivElement | null)[]>([]); - const startCounting = () => { + const startCounting = (index: number): void => { const interval = setInterval(() => { - setStatsData((prev) => - prev.map((num, index) => Math.min(num + maxNumbers[index] / 15, maxNumbers[index])) - ); + setStatsData((prev) => { + const newStats = [...prev]; + newStats[index] = Math.min( + newStats[index] + maxNumbers[index] / 15, + maxNumbers[index] + ); + return newStats; + }); }, 50); - return () => clearInterval(interval); + return () => clearInterval(interval); }; useEffect(() => { - const observer = new IntersectionObserver( - ([entry]) => { - console.log("Intersection Observer callback triggered"); // Log every time the observer is triggered - console.log("Is intersecting:", entry.isIntersecting); // Log whether the section is intersecting or not - console.log("Intersection Ratio:", entry.intersectionRatio); // Log how much of the section is visible - - if (entry.isIntersecting) { - console.log("Section is in view. Starting count-up!"); // Log when the count-up is about to start - startCounting(); - } - }, - { threshold: 0.99 } // % of the section that must be visible + const observers = itemRefs.current.map( + (ref, index): IntersectionObserver | null => { + if (!ref) return null; + + const observer = new IntersectionObserver( + ([entry]) => { + if (entry.isIntersecting && !animated[index]) { + setAnimated((prev) => { + const updated = [...prev]; + updated[index] = true; + return updated; + }); + startCounting(index); + } + }, + { threshold: 0.4 } + ); + + observer.observe(ref); + return observer; + } ); - - if (sectionRef.current) { - console.log("Observing section:", sectionRef.current); // Log when the observer starts observing the section - observer.observe(sectionRef.current); - } - + return () => { - if (sectionRef.current) { - console.log("Unobserving section:", sectionRef.current); // Log when the observer stops observing the section - observer.unobserve(sectionRef.current); - } + observers.forEach((observer, index) => { + if (observer && itemRefs.current[index]) { + observer.unobserve(itemRefs.current[index]!); + } + }); }; - }, []); - + }, [animated]); return ( -
+
Get Involved -
-
+
+
{statsData.map((stat, index) => ( -
+
+ (itemRefs.current[index] = el) + } + > {Math.round(stat) + (Math.round(stat) === maxNumbers[index] ? "+" : "")} @@ -86,9 +108,13 @@ const Stats = () => { {descriptions[index]}