@@ -174,22 +174,35 @@ checkPWA();*/
174174
175175// add scroll event listeners
176176
177- const screenHeight = window . innerHeight ;
177+ const screenHeight = window . innerHeight ,
178+ featurePoints = document . querySelectorAll ( '#features .ftPoint' ) ,
179+
180+ pointMargin = 34 ,
181+ startPointAnimation = ( screenHeight / 3 ) + pointMargin ,
182+
183+
184+ let totalPointAnimation = startPointAnimation ,
185+ pointStaggerIntervals = [ ] ;
178186
179- const featurePoints = document . querySelectorAll ( '#features .ftPoint' ) ;
187+ // set stagger intervals for feature points
188+ featurePoints . forEach ( point => {
180189
181- const startPointAnimation = screenHeight / 3 ;
182- const pointStaggerInterval = 34 + ( 7 * 5 ) ;
190+ totalPointAnimation += point . clientHeight + 34 ;
183191
184- function checkScrollAnimations ( ) {
192+ pointStaggerIntervals . push ( totalPointAnimation ) ;
193+
194+ } ) ;
195+
196+
197+ function checkPointAnimations ( ) {
185198
186199 // window scroll position
187200 const scrolled = window . scrollY || window . pageYOffset ;
188-
189- // add staggered feature points animation
201+
202+ // check feature point animation
190203 featurePoints . forEach ( ( point , index ) => {
191-
192- const pointAnimation = startPointAnimation + ( pointStaggerInterval * index ) ;
204+
205+ const pointAnimation = pointStaggerIntervals [ index ] ;
193206
194207 if ( scrolled >= pointAnimation ) {
195208 point . classList . add ( 'visible' ) ;
@@ -202,5 +215,5 @@ function checkScrollAnimations() {
202215}
203216
204217
205- window . addEventListener ( 'scroll' , checkScrollAnimations ) ;
218+ window . addEventListener ( 'scroll' , checkPointAnimations ) ;
206219checkScrollAnimations ( ) ;
0 commit comments