mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-26 17:54:52 +02:00
some polish
This commit is contained in:
32
docs/js/site/disqus.js
Normal file
32
docs/js/site/disqus.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const comments = document.getElementById(`disqus_thread`);
|
||||
|
||||
document.addEventListener("scroll", scrollHandler, { passive: true });
|
||||
|
||||
function scrollHandler() {
|
||||
var bbox = comments.getBoundingClientRect();
|
||||
var top = bbox.top;
|
||||
var limit = window.innerHeight;
|
||||
if (top < limit) {
|
||||
loadDisqus();
|
||||
}
|
||||
}
|
||||
|
||||
let loadDisqus = () => {
|
||||
console.log(`loading Disqus comments`);
|
||||
|
||||
globalThis.disqus_config = function () {
|
||||
this.page.url = "https://pomax.github.io/bezierinfo";
|
||||
this.page.identifier = "bezierinfo";
|
||||
};
|
||||
|
||||
const script = document.createElement("script");
|
||||
script.src = "https://bezierinfo.disqus.com/embed.js";
|
||||
script.async = true;
|
||||
script.setAttribute("data-timestamp", Date.now());
|
||||
document.head.appendChild(script);
|
||||
|
||||
loadDisqus = () => {};
|
||||
document.removeEventListener("scroll", scrollHandler);
|
||||
};
|
||||
|
||||
scrollHandler();
|
Reference in New Issue
Block a user