@@ -25,17 +25,23 @@ function animateReedsParting() {
2525
2626/**
2727 * Animates the duck swimming left to right.
28+ * Added code so it has a consistent velocity.
2829 */
2930function animateDucky ( ) {
3031 const duck = document . getElementById ( 'animated-duck-container' ) ;
3132
33+ // Get the width of the duck and have it start off the screen, based on its width
3234 const start = - duck . getBoundingClientRect ( ) . width ;
35+ // and the width of the viewport
3336 const end = window . innerWidth ;
3437
38+ // Get the distance the duck needs to travel and move it at a rate of 100px per second.
3539 const distance = end - start ;
3640 const duration = distance / 100 ; // measured in pixels
3741
42+ // Set the duck to start at the left side
3843 gsap . set ( duck , { left : start } ) ;
44+ // Move it to the right, repeat infinitely
3945 gsap . to ( '#animated-duck-container' , {
4046 left : end ,
4147 repeat : - 1 , // infinitely loop
@@ -59,8 +65,8 @@ function imagePopIn() {
5965 } ,
6066 y : '5vh' ,
6167 opacity : 0 ,
62- duration : 1.2 ,
63- ease : 'power3.out ' ,
68+ duration : 0.5 ,
69+ ease : 'none ' ,
6470 stagger : 0.2
6571 } ) ;
6672 } ) ;
@@ -99,11 +105,53 @@ function handleHeaderChanges() {
99105 } ) ;
100106}
101107
108+ /**
109+ * Controls the countdown on the hero
110+ */
111+ function setCountdown ( ) {
112+ // Target time is September 8, 2025 PDT @ 1PM
113+ const target = new Date ( '2025-09-08T13:00:00.000-07:00' ) . getTime ( ) ;
114+
115+ // Don't show the countdown if it's past the Frosh start date.
116+ if ( target < new Date ( ) . getTime ( ) ) {
117+ document . getElementById ( 'countdown' ) . style . display = 'none' ;
118+ return ;
119+ }
120+ const secToMs = 1000 ;
121+ const minToMs = secToMs * 60 ;
122+ const hourToMs = minToMs * 60 ;
123+ const dayToMs = hourToMs * 24 ;
124+
125+ const secEle = document . getElementById ( 'cd-sec' ) ;
126+ const minEle = document . getElementById ( 'cd-min' ) ;
127+ const hourEle = document . getElementById ( 'cd-hour' ) ;
128+ const dayEle = document . getElementById ( 'cd-day' ) ;
129+
130+ let update = ( ) => {
131+ const now = new Date ( ) . getTime ( ) ;
132+ let difference = target - now ;
133+
134+ let secs = Math . floor ( ( difference / secToMs ) % 60 ) ;
135+ let mins = Math . floor ( ( difference / minToMs ) % 60 ) ;
136+ let hours = Math . floor ( ( difference / hourToMs ) % 24 ) ;
137+ let days = Math . floor ( difference / dayToMs ) ;
138+
139+ secEle . textContent = secs ;
140+ minEle . textContent = mins ;
141+ hourEle . textContent = hours ;
142+ dayEle . textContent = days ;
143+ } ;
144+
145+ update ( ) ;
146+ setInterval ( update , 1000 ) ;
147+ }
148+
102149window . addEventListener ( 'load' , _ => {
103150 gsap . registerPlugin ( ScrollTrigger , ScrollSmoother ) ;
104151 animateReedsParting ( ) ;
105152 handleHeaderChanges ( ) ;
106153 animateDucky ( ) ;
154+ setCountdown ( ) ;
107155 if ( window . matchMedia ( '(min-width: 1280px' ) . matches ) {
108156 imagePopIn ( ) ;
109157 }
0 commit comments