docs: Have menuspy recalculate positions after all images have been loaded Fixes #99

This commit is contained in:
Jennifer Shehane
2017-07-06 17:21:33 -04:00
parent d37fddb6ff
commit 571ebe48cf

View File

@@ -9,10 +9,17 @@
if (!toc) return;
// https://github.com/lcdsantos/menuspy
// This highlights the proper toc link while scrolling
var ms = new MenuSpy(tocInner)
// we need this to be called after all images have loaded
// otherwise the height for the menuspy is not properly calculated
window.addEventListener('load', function(){
// https://github.com/lcdsantos/menuspy
// This highlights the proper toc link while scrolling
ms.cacheItems()
ms.tick()
});
// This keeps the toc within the view
function updateSidebarPosition(){
var scrollTop = document.scrollingElement.scrollTop;