Skip to content

Commit f3dad85

Browse files
committed
added new animation
1 parent 12a1f07 commit f3dad85

2 files changed

Lines changed: 61 additions & 8 deletions

File tree

src/App.tsx

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { useEffect, useRef } from "react";
2+
import gsap from "gsap";
3+
import { ScrollTrigger } from "gsap/ScrollTrigger";
14
import AboutMe from "./components/aboutMe";
25
import Beams from "./components/blocks/Backgrounds/Beams/Beams";
36
import Hero from "./components/hero";
@@ -7,9 +10,42 @@ import Projects from "./components/projects";
710
import Contact from "./components/contact";
811
import Footer from "./components/footer";
912

13+
gsap.registerPlugin(ScrollTrigger);
14+
1015
export default function App() {
16+
const mainRef = useRef<HTMLDivElement>(null);
17+
18+
useEffect(() => {
19+
const ctx = gsap.context(() => {
20+
const sections = gsap.utils.toArray<HTMLElement>(".reveal-section");
21+
22+
sections.forEach((section) => {
23+
gsap.fromTo(
24+
section,
25+
{ autoAlpha: 0, y: 20 },
26+
{
27+
autoAlpha: 1,
28+
y: 0,
29+
duration: 0.8,
30+
ease: "power1.out",
31+
scrollTrigger: {
32+
trigger: section,
33+
start: "top 92%",
34+
end: "bottom 8%",
35+
toggleActions: "play reverse play reverse",
36+
// Using scrub: false but keeping it light
37+
invalidateOnRefresh: true,
38+
},
39+
}
40+
);
41+
});
42+
}, mainRef);
43+
44+
return () => ctx.revert();
45+
}, []);
46+
1147
return (
12-
<div className="relative w-full min-h-screen overflow-auto dark">
48+
<div className="relative w-full min-h-screen overflow-x-hidden dark" ref={mainRef}>
1349
<div className="fixed inset-0 z-10 pointer-events-none">
1450
<Beams
1551
beamWidth={2}
@@ -28,12 +64,24 @@ export default function App() {
2864
</header>
2965

3066
<main className="relative z-10 mt-4 merienda">
31-
<Hero imageSrc="/assets/profile_pic_2.png" />
32-
<Skills />
33-
<AboutMe />
34-
<Projects />
35-
<Contact />
36-
<Footer />
67+
<div className="reveal-section">
68+
<Hero imageSrc="/assets/profile_pic_2.png" />
69+
</div>
70+
<div className="reveal-section">
71+
<Skills />
72+
</div>
73+
<div className="reveal-section">
74+
<AboutMe />
75+
</div>
76+
<div className="reveal-section">
77+
<Projects />
78+
</div>
79+
<div className="reveal-section">
80+
<Contact />
81+
</div>
82+
<div className="reveal-section">
83+
<Footer />
84+
</div>
3785
</main>
3886
</div>
3987
);

src/index.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
}
5252

5353
html {
54-
scroll-behavior: smooth;
5554
}
5655

5756
.manufacturing-consent-regular {
@@ -175,3 +174,9 @@ html {
175174
@apply bg-background text-foreground;
176175
}
177176
}
177+
178+
.reveal-section {
179+
opacity: 0;
180+
visibility: hidden;
181+
will-change: transform, opacity;
182+
}

0 commit comments

Comments
 (0)