1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-30 03:30:34 +02:00

bit of cleanup

This commit is contained in:
Pomax
2017-04-15 12:21:12 -07:00
parent 667fbfae0b
commit 842fd8e344
35 changed files with 185 additions and 230 deletions

View File

@@ -3443,14 +3443,42 @@ return {
}())
},
"comments": {
handler: (function() { return {
handler: (function() { /**
* We REALLY don't want disqus to load unless the user
* is actually looking at the comments section, because it
* tacks on 2.5+ MB in network transfers...
*/
return {
componentDidMount() {
if (typeof document !== "undefined") {
var script = document.createElement("script");
script.src = "lib/site/disqus.js";
script.async = true;
document.head.appendChild(script);
if (typeof document === "undefined") {
return this.silence();
}
this.heading = document.getElementById(this.props.page);
document.addEventListener("scroll", this.scrollHandler, {passive:true});
},
scrollHandler(evt) {
var bbox = this.heading.getBoundingClientRect();
var top = bbox.top;
var limit = window.innerHeight;
if (top<limit) { this.loadDisqus(); }
},
loadDisqus() {
var script = document.createElement("script");
script.src = "lib/site/disqus.js";
script.async = true;
document.head.appendChild(script);
this.silence();
this.unlisten();
},
silence() {
this.loadDisqus = () => {};
},
unlisten() {
document.removeEventListener("scroll", this.scrollHandler);
}
};
}())