Well looks like my scroll listener queueing method was wrong

This commit is contained in:
Chuck Dries 2017-11-01 23:10:39 -07:00
parent f05ea4ae3d
commit a0ce83a332

View File

@ -255,15 +255,18 @@
var sp = document.getElementById("scrollprompt"); var sp = document.getElementById("scrollprompt");
document.addEventListener("scroll", function () { document.addEventListener("scroll", function () {
last_known_scroll = getScrollY(); last_known_scroll = getScrollY();
// sc(last_known_scroll);
// Usually an important performance consideration, this ends up significantly delaying the resizing of the top box, which is important to stay sized correctly
if (!queueing) { if (!queueing) {
window.requestAnimationFrame(function () { window.requestAnimationFrame(function () {//"queue up" animation
sc(last_known_scroll);
queueing = false; queueing = false;
sc(last_known_scroll);
}); });
queueing = true;
} }
queueing = true; });
window.addEventListener("resize",function() {
last_known_scroll = getScrollY();
sc(last_known_scroll);
}); });
sc(last_known_scroll); sc(last_known_scroll);
@ -284,7 +287,7 @@
} }
// var mastHeight = mast.clientHeight; // var mastHeight = mast.clientHeight;
// var halfHeight = Math.floor((topHeight / 2) - (mastHeight / 2)); // var halfHeight = Math.floor((topHeight / 2) - (mastHeight / 2));
if (topHeight < 360) { if (topHeight < 310) {
topDiv.className = "small"; topDiv.className = "small";
} else { } else {
topDiv.className = "large"; topDiv.className = "large";