Skip to content

Commit 0e77fd9

Browse files
committed
Update index.html
1 parent b4ea279 commit 0e77fd9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,15 @@ <h2 class="color-1 weight-title-h font-title section__title center">A codeful of
325325

326326
function checkScrollAnimations() {
327327

328+
featurePoints.forEach(point => {
329+
330+
const visible = isScrolledIntoView(point);
331+
332+
point.classList.toggle('visible', visible);
333+
334+
});
335+
336+
/*
328337
// window scroll position
329338
const scrolled = window.scrollY || window.pageYOffset;
330339
@@ -340,7 +349,24 @@ <h2 class="color-1 weight-title-h font-title section__title center">A codeful of
340349
}
341350
342351
});
352+
*/
353+
354+
}
355+
356+
function isScrolledIntoView(el) {
357+
358+
const rect = el.getBoundingClientRect();
359+
const elemTop = rect.top;
360+
const elemBottom = rect.bottom;
361+
362+
// Only completely visible elements return true:
363+
const isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight);
364+
365+
// Partially visible elements return true:
366+
// isVisible = elemTop < window.innerHeight && elemBottom >= 0;
343367

368+
return isVisible;
369+
344370
}
345371

346372
window.addEventListener('scroll', checkScrollAnimations);

0 commit comments

Comments
 (0)