Skip to content

Commit 94ea7da

Browse files
added scroll counting effect
1 parent 6979c1d commit 94ea7da

File tree

4 files changed

+149
-8
lines changed

4 files changed

+149
-8
lines changed

.env.sample

Lines changed: 0 additions & 2 deletions
This file was deleted.

package-lock.json

Lines changed: 133 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"progressbar": "^1.3.0",
1515
"react": "^18.2.0",
1616
"react-chartjs-2": "^5.2.0",
17+
"react-countup": "^6.5.3",
1718
"react-dom": "^18.2.0",
1819
"react-dropzone": "^14.2.3",
1920
"react-hook-form": "^7.45.4",
@@ -25,6 +26,7 @@
2526
"react-redux": "^8.1.2",
2627
"react-router-dom": "^6.14.2",
2728
"react-scripts": "5.0.1",
29+
"react-scroll-trigger": "^0.6.14",
2830
"react-super-responsive-table": "^5.2.2",
2931
"react-type-animation": "^3.1.0",
3032
"redux": "^4.2.1",

src/components/core/About/Stats.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
1-
import React from "react";
1+
import React, {useState} from "react";
2+
import CountUp from 'react-countup';
3+
import ScrollTrigger from 'react-scroll-trigger';
24
const data = [
3-
{ count: "5K", label: "Active Students" },
4-
{ count: "10+", label: "Mentors" },
5-
{ count: "200+", label: "Courses" },
6-
{ count: "50+", label: "Awards" },
5+
{ count: "5000", label: "Active Students" },
6+
{ count: "10", label: "Mentors" },
7+
{ count: "200", label: "Courses" },
8+
{ count: "50", label: "Awards" },
79
];
810
export default function Stats() {
11+
const [count, setCount] = useState(false)
912
return (
1013
<div className="flex flex-col gap-10 justify-between w-11/12 max-w-maxContent text-white mx-auto ">
14+
1115
<div className="grid grid-cols-2 md:grid-cols-4 text-center">
1216
{data.map((item, index) => {
1317
return (
18+
<ScrollTrigger onEnter={()=> setCount(true)} onExit={()=>setCount(false)}>
1419
<div className="flex flex-col py-10" key={index}>
1520
<h1 className="text-[30px] font-bold text-richblack-5">
16-
{item.count}
21+
{count && <CountUp start={0} end={item.count} duration={1}>
22+
</CountUp>}+
1723
</h1>
1824
<h2 className="font-semibold text-[16px] text-richblack-500">
1925
{item.label}
2026
</h2>
2127
</div>
28+
</ScrollTrigger>
2229
);
2330
})}
2431
</div>
32+
2533
</div>
2634
);
2735
}

0 commit comments

Comments
 (0)