mirror of
https://git.topisto.net/tibo/template.git
synced 2026-03-31 19:29:10 +00:00
initialisation with SMETI code
This commit is contained in:
19
frontend/src/scripts/UI/IntersectionObserver/footer.js
Normal file
19
frontend/src/scripts/UI/IntersectionObserver/footer.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// Create a function that will handle any intersection between some elements and the viewport.
|
||||
const handleFooterIntersection = function (entries) {
|
||||
// Loop through all the observed elements
|
||||
for (let entry of entries) {
|
||||
// Check if the element is intersecting the viewport
|
||||
if (entry.isIntersecting) {
|
||||
console.log("The footer is visible in the viewport");
|
||||
if (typeof footerIsNowVisible === 'function') footerIsNowVisible(entry);
|
||||
} else {
|
||||
console.log("The footer is invisible in the viewport");
|
||||
if (typeof footerIsNowInvisible === 'function') footerIsNowInvisible(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
const footer = document.querySelector("#footer");
|
||||
if (footer) {
|
||||
const footerObserver = new IntersectionObserver(handleFooterIntersection);
|
||||
footerObserver.observe(footer);
|
||||
}
|
||||
Reference in New Issue
Block a user