Skip to the content
Drag
document.addEventListener("DOMContentLoaded", function () {
const lazyPages = document.querySelectorAll(".lazy-page");
const observer = new IntersectionObserver(
(entries, obs) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const container = entry.target;
const pageUrl = container.dataset.url;
fetch(pageUrl)
.then((res) => res.text())
.then((html) => {
const tempDiv = document.createElement("div");
tempDiv.innerHTML = html;
const elementorContent = tempDiv.querySelector(".elementor");
if (elementorContent) {
const newContent = elementorContent.innerHTML;
// הוספת DIV עם קלאס אנימציה
container.innerHTML = `${newContent}
`;
} else {
container.innerHTML = "לא נמצא תוכן לטעינה.
";
}
obs.unobserve(container);
});
}
});
},
{ rootMargin: "100px" }
);
lazyPages.forEach((page) => {
observer.observe(page);
});
});