@@ -22,8 +22,9 @@ import Tracks from "./(TracksSectionComponents)/TracksTabNavigation/Tracks";
2222import { Track } from "@/src/util/dataTypes" ;
2323
2424import LivePoll from "./(AboutSectionComponents)/LivePoll" ;
25+ import { actionSetTracksAnimation } from "@/src/util/actions/animation" ;
2526
26- const TracksSection = ( ) => {
27+ const TracksSection = ( { noTrackAnimation } : { noTrackAnimation : boolean } ) => {
2728 const panelMargin = "mt-12 md:mt-16" ;
2829
2930 // tracks contains all relevant information about each of the 6 tracks
@@ -37,6 +38,10 @@ const TracksSection = () => {
3738 const [ startAnimation , setStartAnimation ] = useState ( false ) ;
3839
3940 useEffect ( ( ) => {
41+ if ( noTrackAnimation ) {
42+ return ;
43+ }
44+
4045 // set initial animation state for tracks comp
4146 gsap . set ( tracksNavRef . current , {
4247 height : 0 ,
@@ -121,9 +126,13 @@ const TracksSection = () => {
121126 } ) . to ( livePollRef . current , {
122127 duration : 0.3 ,
123128 opacity : 1 ,
129+ onComplete : ( ) => {
130+ // set cookies storage to prevent animation from playing again
131+ actionSetTracksAnimation ( ) ;
132+ } ,
124133 } ) ;
125134 }
126- } , [ showTracks ] ) ;
135+ } , [ showTracks , noTrackAnimation ] ) ;
127136
128137 return (
129138 < Panel id = "tracksPanel" className = { panelMargin } panelColor = "white" >
@@ -137,22 +146,26 @@ const TracksSection = () => {
137146 </ PanelHeader >
138147
139148 < div ref = { panelContentRef } >
140- < PanelContent
141- parentPanelId = "tracksPanel"
142- className = "relative flex flex-col items-center"
143- >
144- < QuestionMark className = "w-[65px] md:w-[80px] lg:w-[100px] xl:w-[125px] top-[10%] left-[8%] rotate-[19deg]" />
145- < QuestionMark className = "w-[65px] md:w-[80px] lg:w-[100px] xl:w-[125px] top-[20%] right-[14%] -rotate-[15deg]" />
146- < QuestionMark className = "w-[65px] md:w-[80px] lg:w-[100px] xl:w-[125px] bottom-[10%] left-[16%] rotate-[28deg]" />
147- < QuestionMark className = "w-[65px] md:w-[80px] lg:w-[100px] xl:w-[125px] bottom-[3%] right-[20%] -rotate-[40deg]" />
148-
149- { /* Pass name of each track as contents of mystery box */ }
150- < MysteryBox
151- contents = { tracks . map ( ( track ) => track [ "name" ] ) }
152- startAnimation = { startAnimation }
153- setShowTracks = { setShowTracks }
154- />
155- </ PanelContent >
149+ { ! noTrackAnimation && (
150+ < PanelContent
151+ parentPanelId = "tracksPanel"
152+ className = "relative flex flex-col items-center"
153+ >
154+ < >
155+ < QuestionMark className = "w-[65px] md:w-[80px] lg:w-[100px] xl:w-[125px] top-[10%] left-[8%] rotate-[19deg]" />
156+ < QuestionMark className = "w-[65px] md:w-[80px] lg:w-[100px] xl:w-[125px] top-[20%] right-[14%] -rotate-[15deg]" />
157+ < QuestionMark className = "w-[65px] md:w-[80px] lg:w-[100px] xl:w-[125px] bottom-[10%] left-[16%] rotate-[28deg]" />
158+ < QuestionMark className = "w-[65px] md:w-[80px] lg:w-[100px] xl:w-[125px] bottom-[3%] right-[20%] -rotate-[40deg]" />
159+ </ >
160+
161+ { /* Pass name of each track as contents of mystery box */ }
162+ < MysteryBox
163+ contents = { tracks . map ( ( track ) => track [ "name" ] ) }
164+ startAnimation = { startAnimation }
165+ setShowTracks = { setShowTracks }
166+ />
167+ </ PanelContent >
168+ ) }
156169 </ div >
157170
158171 < Tracks
0 commit comments