Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Whitzzscott authored Sep 3, 2024
1 parent ace0fb3 commit aed5041
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -141,6 +142,35 @@ <h2>Suggestion Accepted!</h2>
});
};
</script>
<script>
// Add this script to detect scroll and add 'visible' class when elements are in view
document.addEventListener("DOMContentLoaded", function () {
const scrollElements = document.querySelectorAll('.scroll-element');

const elementInView = (el, dividend = 1) => {
const elementTop = el.getBoundingClientRect().top;
return (elementTop <= (window.innerHeight || document.documentElement.clientHeight) / dividend);
};

const displayScrollElement = (element) => {
element.classList.add('visible');
};

const handleScrollAnimation = () => {
scrollElements.forEach((el) => {
if (elementInView(el, 1.25)) {
displayScrollElement(el);
}
});
};

window.addEventListener('scroll', () => {
handleScrollAnimation();
});

handleScrollAnimation();
});
</script>
<script>
window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
</script>
Expand Down

0 comments on commit aed5041

Please sign in to comment.