1
0
mirror of https://git.topisto.net/tibo/template.git synced 2026-03-31 23:49:11 +00:00

Homogénéiser les IntersectionObserver

This commit is contained in:
Thibaud
2024-09-13 18:02:31 +02:00
parent 2030381b45
commit 51970485f2
3 changed files with 31 additions and 25 deletions

View File

@@ -1,12 +1,15 @@
const headerObserver = new IntersectionObserver(entries => {
// 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') headerIsVisible(entry.isIntersecting);
if (typeof headerIsVisible === 'function') headerIsNowVisible(entry.isIntersecting);
});
});
}
const header = document.querySelector("header");
if (header) headerObserver.observe(header);
else myLog('No header to observe');
const section_header = document.querySelector("header");
if (section_header) {
const headerObserver = new IntersectionObserver(handleSynthesisIntersection);
if (headerObserver) headerObserver.observe(section_header);
} else myLog('No header to observe');