@@ -6,9 +6,12 @@ import { ScrollTrigger } from 'gsap/ScrollTrigger';
66gsap . registerPlugin ( ScrollTrigger ) ;
77
88export function initGSAPAnimations ( ) {
9- if ( typeof window === 'undefined' ) return ;
10- // Animate elements with fade-up effect on scroll
9+ if ( typeof window === 'undefined' ) return ; // Animate elements with fade-up effect on scroll
1110 gsap . utils . toArray ( '.gsap-fade-up' ) . forEach ( ( element ) => {
11+ // Check if the element is inside the contact section
12+ const isInsideContactSection = element . closest ( '#contact' ) !== null ;
13+ const toggleActions = isInsideContactSection ? 'play none play none' : 'play reverse play reverse' ;
14+
1215 gsap . fromTo ( element ,
1316 {
1417 opacity : 0 ,
@@ -23,7 +26,7 @@ export function initGSAPAnimations() {
2326 trigger : element ,
2427 start : 'top 80%' ,
2528 end : 'bottom 10%' ,
26- toggleActions : 'play reverse play reverse'
29+ toggleActions : toggleActions
2730 }
2831 }
2932 ) ;
@@ -44,9 +47,12 @@ export function initGSAPAnimations() {
4447 delay : index * 0.2
4548 }
4649 ) ;
47- } ) ;
48- // Animate sections with a slight scale effect
50+ } ) ; // Animate sections with a slight scale effect
4951 gsap . utils . toArray ( '.gsap-section' ) . forEach ( ( element ) => {
52+ // Check if the element has id="contact" to avoid reversing animation
53+ const isContactSection = element . id === 'contact' ;
54+ const toggleActions = isContactSection ? 'play none play none' : 'play reverse play reverse' ;
55+
5056 gsap . fromTo ( element ,
5157 {
5258 opacity : 0 ,
@@ -61,7 +67,7 @@ export function initGSAPAnimations() {
6167 trigger : element ,
6268 start : 'top 85%' ,
6369 end : 'bottom 15%' ,
64- toggleActions : 'play reverse play reverse'
70+ toggleActions : toggleActions
6571 }
6672 }
6773 ) ;
0 commit comments