Skip to content

Commit 4817806

Browse files
committed
Update index.html
1 parent f1c08c9 commit 4817806

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

index.html

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,13 @@ <h2 class="color-1 weight-title-h font-title section__title center">A codeful of
348348
const featurePoints = document.querySelectorAll('#features .ftPoint');
349349
const themeColorTag = document.querySelector('meta[name="theme-color"]');
350350
const heroEl = document.querySelector('#hero');
351+
const footerEl = document.querySelector('#footer');
351352

352353
function 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+
391413
window.addEventListener('scroll', checkScrollAnimations);
392414
checkScrollAnimations();
393415

0 commit comments

Comments
 (0)