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:
@@ -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');
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user