Update ajax to use intersection observer
This commit is contained in:
parent
2f4c21397b
commit
1c0186d4fe
@ -185,6 +185,13 @@ module.exports = {
|
|||||||
|
|
||||||
document.querySelectorAll("article").forEach((a) => {
|
document.querySelectorAll("article").forEach((a) => {
|
||||||
if ( a.getAttribute("data-template") != "none" ) {
|
if ( a.getAttribute("data-template") != "none" ) {
|
||||||
|
|
||||||
|
const observer = new IntersectionObserver((articles, { threshold: 0, rootMargin: 50vh}) => {
|
||||||
|
articles.forEach(article => {
|
||||||
|
let a = article.target;
|
||||||
|
|
||||||
|
if (article.isIntersecting) {
|
||||||
|
|
||||||
let path = a.getAttribute("data-path");
|
let path = a.getAttribute("data-path");
|
||||||
path = "patterns/" +
|
path = "patterns/" +
|
||||||
(a.getAttribute("data-core") == "true" ?
|
(a.getAttribute("data-core") == "true" ?
|
||||||
@ -267,6 +274,13 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
ajx.open("GET", path, ASYNC);
|
ajx.open("GET", path, ASYNC);
|
||||||
ajx.send();
|
ajx.send();
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
observer.observe(a);
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user