// Create a function that will handle any intersection between some elements and the viewport.
const handleSynthesisIntersection = function (entries) {
  entries.forEach(entry => {
    // Check if the element is intersecting the viewport
    if (entry.isIntersecting) {
      msgConsole('IntersectionObserver',"The synthesis is visible in the viewport");
      if (typeof synthesisIsNowVisible === 'function') synthesisIsNowVisible(entry);
    } else {
      msgConsole('IntersectionObserver',"The synthesis is invisible in the viewport");
      if (typeof synthesisIsNowInvisible === 'function') synthesisIsNowInvisible(entry);
    }
  });
}

const section_synthesis = document.querySelector("#synthesis");
if (section_synthesis) {
    const synthesisObserver = new IntersectionObserver(handleSynthesisIntersection);
    if (synthesisObserver) synthesisObserver.observe(section_synthesis);
} else myLog('No #synthesis to observe');

