@@ -8,6 +8,8 @@ import Image, { StaticImageData } from "next/image";
88import images from "@/images" ;
99import TypingText from "@/components/shared/TypingText" ;
1010import phrases from "@/data/homeHeroPhrases" ;
11+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
12+ import { faChevronDown } from "@fortawesome/free-solid-svg-icons" ;
1113
1214gsap . registerPlugin ( ScrollTrigger ) ;
1315
@@ -21,11 +23,13 @@ export const Hero: React.FC<HeroProps> = ({ id, backgroundImage }) => {
2123 const parallaxBackground = useRef < HTMLDivElement > ( null ) ;
2224 const profilePictureContainer = useRef < HTMLDivElement > ( null ) ;
2325 const textContentContainer = useRef < HTMLDivElement > ( null ) ;
26+ const foregroundContainer = useRef < HTMLDivElement > ( null ) ;
2427
2528 useGSAP (
2629 ( ) => {
30+ // Move background image up by 10% slower than scroll
2731 gsap . to ( parallaxBackground . current , {
28- yPercent : - 10 , // Moves the background image up by 20% slower than scroll
32+ yPercent : - 10 ,
2933 ease : "none" ,
3034 scrollTrigger : {
3135 trigger : container . current ,
@@ -35,45 +39,79 @@ export const Hero: React.FC<HeroProps> = ({ id, backgroundImage }) => {
3539 } ,
3640 } ) ;
3741
38- ScrollTrigger . create ( {
39- trigger : container . current ,
40- start : "top" ,
41- end : "bottom 60%" ,
42- scrub : true ,
43- animation : gsap . fromTo (
44- profilePictureContainer . current ,
45- {
46- width : ( ) => profilePictureContainer . current ?. offsetWidth || 16 ,
47- height : ( ) => profilePictureContainer . current ?. offsetHeight || 16 ,
48- } ,
49- {
50- width : ( ) =>
51- ( profilePictureContainer . current ?. offsetWidth || 8 ) / 2 ,
52- height : ( ) => profilePictureContainer . current ?. offsetHeight || 16 ,
53- duration : 0.5 ,
54- ease : "power1.out" ,
55- }
56- ) ,
42+ const timeline = gsap . timeline ( {
43+ scrollTrigger : {
44+ trigger : container . current ,
45+ start : "top" ,
46+ end : "bottom 60%" ,
47+ scrub : true ,
48+ } ,
5749 } ) ;
5850
59- ScrollTrigger . create ( {
60- trigger : container . current ,
61- start : "top" ,
62- end : "bottom 60%" ,
63- scrub : true ,
64- animation : gsap . fromTo (
65- textContentContainer . current ,
66- {
67- opacity : 1 ,
68- } ,
69- {
70- opacity : 0 ,
71- y : "-20%" ,
72- duration : 1 ,
73- ease : "power1.out" ,
74- }
75- ) ,
51+ // Resize picture
52+ timeline . fromTo (
53+ profilePictureContainer . current ,
54+ {
55+ width : ( ) => profilePictureContainer . current ?. offsetWidth || 16 ,
56+ height : ( ) => profilePictureContainer . current ?. offsetHeight || 16 ,
57+ } ,
58+ {
59+ width : ( ) => ( profilePictureContainer . current ?. offsetWidth || 8 ) / 2 ,
60+ height : ( ) => profilePictureContainer . current ?. offsetHeight || 16 ,
61+ duration : 0.5 ,
62+ ease : "power1.out" ,
63+ }
64+ ) ;
65+
66+ // Fade up and out content
67+ timeline . to ( foregroundContainer . current , {
68+ opacity : 0 ,
69+ y : "-20%" ,
70+ duration : 1 ,
71+ ease : "power1.out" ,
7672 } ) ;
73+
74+ // Initial animation
75+ // ScrollTrigger.create({
76+ // trigger: container.current,
77+ // start: "top",
78+ // end: "bottom 60%",
79+ // scrub: true,
80+ // animation: gsap.fromTo(
81+ // profilePictureContainer.current,
82+ // {
83+ // width: () => profilePictureContainer.current?.offsetWidth || 16,
84+ // height: () => profilePictureContainer.current?.offsetHeight || 16,
85+ // },
86+ // {
87+ // width: () =>
88+ // (profilePictureContainer.current?.offsetWidth || 8) / 2,
89+ // height: () => profilePictureContainer.current?.offsetHeight || 16,
90+ // duration: 0.5,
91+ // ease: "power1.out",
92+ // }
93+ // ),
94+ // });
95+
96+ // Move text content up and fade out
97+ // ScrollTrigger.create({
98+ // trigger: container.current,
99+ // start: "top",
100+ // end: "bottom 60%",
101+ // scrub: true,
102+ // animation: gsap.fromTo(
103+ // textContentContainer.current,
104+ // {
105+ // opacity: 1,
106+ // },
107+ // {
108+ // opacity: 0,
109+ // y: "-20%",
110+ // duration: 1,
111+ // ease: "power1.out",
112+ // }
113+ // ),
114+ // });
77115 } ,
78116 {
79117 scope : container ,
@@ -106,7 +144,7 @@ export const Hero: React.FC<HeroProps> = ({ id, backgroundImage }) => {
106144 < div className = "absolute inset-0 bg-black opacity-20 dark:opacity-50" />
107145
108146 { /* Foreground Content */ }
109- < div className = "relative z-10" >
147+ < div ref = { foregroundContainer } className = "relative z-10" >
110148 < div className = "flex justify-center items-center flex-col" >
111149 < div
112150 ref = { profilePictureContainer }
@@ -121,11 +159,11 @@ export const Hero: React.FC<HeroProps> = ({ id, backgroundImage }) => {
121159 priority
122160 />
123161 </ div >
124- < div ref = { textContentContainer } >
125- < h1 className = "text-white text- 4xl md:mb-2 md:text-6xl font-bold text-center" >
162+ < div ref = { textContentContainer } className = "text-white" >
163+ < h1 className = "text-4xl md:mb-2 md:text-6xl font-bold text-center" >
126164 Maxwell Lang
127165 </ h1 >
128- < p className = "text-white text- center leading-tight font-light text-2xl md:text-4xl" >
166+ < p className = "text-center leading-tight font-light text-2xl md:text-4xl" >
129167 < span className = "block" >
130168 < TypingText phrases = { phrases } waitTime = { 2000 } />
131169 for
@@ -134,6 +172,9 @@ export const Hero: React.FC<HeroProps> = ({ id, backgroundImage }) => {
134172 { new Date ( ) . getFullYear ( ) - 2018 } years and counting.
135173 </ span >
136174 </ p >
175+ < div className = "animated-content text-center mt-6 animate-bounce" >
176+ < FontAwesomeIcon icon = { faChevronDown } className = "fa-2x" />
177+ </ div >
137178 </ div >
138179 </ div >
139180 </ div >
0 commit comments