Skip to content
Snippets Groups Projects

Resolve "[Page] Complete home page"

Merged Quentin Duvert requested to merge 11-page-complete-home-page into main
5 files
+ 338
48
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 29
0
// Function to replace class "A" with "B"
function replaceClass(element) {
element.classList.add('numbers__window__digit');
element.classList.remove('A');
}
// Function to handle the intersection
function handleIntersection(entries, observer) {
entries.forEach(entry => {
if (entry.isIntersecting) {
// Element is on screen, replace class
replaceClass(entry.target);
// Stop observing this element to avoid unnecessary replacements
observer.unobserve(entry.target);
}
});
}
// Create an Intersection Observer
const observer = new IntersectionObserver(handleIntersection, {
threshold: 0.5, // Adjust the threshold as needed
});
// Find all elements with class "A" and observe them
const elements = document.querySelectorAll('.A');
elements.forEach(element => {
observer.observe(element);
});
\ No newline at end of file
Loading