Optimize message docs

This commit is contained in:
Jeremy Thomas
2017-07-29 14:59:10 +01:00
parent 13d6def032
commit 0e2f716de5
5 changed files with 61 additions and 16 deletions

View File

@@ -11,7 +11,7 @@ document.addEventListener('DOMContentLoaded', () => {
const target = $el.getAttribute('href');
const $target = document.getElementById(target.substring(1));
$target.scrollIntoView(true);
window.history.replaceState(null, document.title, `${window.location.origin}${window.location.pathname}${target}`);
// window.history.replaceState(null, document.title, `${window.location.origin}${window.location.pathname}${target}`);
return false;
});
});
@@ -152,4 +152,27 @@ document.addEventListener('DOMContentLoaded', () => {
return Array.prototype.slice.call(document.querySelectorAll(selector), 0);
}
let latestKnownScrollY = 0;
let ticking = false;
function scrollUpdate() {
ticking = false;
// do stuff
}
function onScroll() {
latestKnownScrollY = window.scrollY;
scrollRequestTick();
}
function scrollRequestTick() {
if(!ticking) {
requestAnimationFrame(scrollUpdate);
}
ticking = true;
}
window.addEventListener('scroll', onScroll, false);
});