1
0
mirror of https://git.topisto.net/tibo/template.git synced 2026-03-31 15:09:10 +00:00
Files
template/frontend/src/scripts/UI/IntersectionObserver/header.js
2024-09-13 18:49:50 +02:00

16 lines
535 B
JavaScript

// Create a function that will handle any intersection between some elements and the viewport.
const handleHeaderIntersection = function (entries) {
entries.forEach(entry => {
if (typeof headerIsVisible === 'function') headerIsNowVisible(entry.isIntersecting);
});
}
const section_header = document.querySelector("header");
if (section_header) {
const headerObserver = new IntersectionObserver(handleHeaderIntersection);
if (headerObserver) headerObserver.observe(section_header);
} else myLog('No header to observe');