@@ -348,12 +348,13 @@ <h2 class="color-1 weight-title-h font-title section__title center">A codeful of
348348const featurePoints = document . querySelectorAll ( '#features .ftPoint' ) ;
349349const themeColorTag = document . querySelector ( 'meta[name="theme-color"]' ) ;
350350const heroEl = document . querySelector ( '#hero' ) ;
351+ const footerEl = document . querySelector ( '#footer' ) ;
351352
352353function checkScrollAnimations ( ) {
353354
354355 featurePoints . forEach ( point => {
355356
356- const visible = isScrolledIntoView ( point ) ;
357+ const visible = isFullyInView ( point ) ;
357358
358359 point . classList . toggle ( 'visible' , visible ) ;
359360
@@ -372,13 +373,23 @@ <h2 class="color-1 weight-title-h font-title section__title center">A codeful of
372373
373374 }
374375
376+
377+ if ( isPartlyInView ( footerEl ) ) {
378+
379+ document . documentElement . style . background = '#24262d' ;
380+
381+ } else {
382+
383+ document . documentElement . style . background = '#1a1c24' ;
384+
385+ }
386+
375387}
376388
377- function isScrolledIntoView ( el ) {
389+ function isFullyInView ( el ) {
378390
379391 const rect = el . getBoundingClientRect ( ) ;
380392 const elemTop = rect . top ;
381- const elemBottom = rect . bottom ;
382393
383394 const height = 51.4 / 2 ; // el.clientHeight;
384395
@@ -388,6 +399,17 @@ <h2 class="color-1 weight-title-h font-title section__title center">A codeful of
388399
389400}
390401
402+ function isPartlyInView ( el ) {
403+
404+ const rect = el . getBoundingClientRect ( ) ;
405+ const elemTop = rect . top ;
406+
407+ const isVisible = elemTop < window . innerHeight ;
408+
409+ return isVisible ;
410+
411+ }
412+
391413window . addEventListener ( 'scroll' , checkScrollAnimations ) ;
392414checkScrollAnimations ( ) ;
393415
0 commit comments