diff options
author | Phil Hughes <me@iamphill.com> | 2017-06-28 19:30:51 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-06-28 19:30:51 +0300 |
commit | 71fde2a147088398005cd789febe1dbb15d15dae (patch) | |
tree | 830f813d4351ba6dc90f7c1fbaa40a01957ad6ea /content | |
parent | 4daf1bdbe303f4bbb73583f993ce64e6fc34e14b (diff) |
Fixed TOC going under the footer
Diffstat (limited to 'content')
-rw-r--r-- | content/assets/javascripts/docs.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/content/assets/javascripts/docs.js b/content/assets/javascripts/docs.js index 4bf4e3ff..f7aabd1e 100644 --- a/content/assets/javascripts/docs.js +++ b/content/assets/javascripts/docs.js @@ -11,6 +11,7 @@ function toggleNavigation() { // move document nav to sidebar (function() { var nav = document.querySelectorAll('.breadcrumbs +ul'); + var main = document.querySelectorAll('.main.class'); // if the document has a top level nav if(nav[0]) { @@ -34,6 +35,18 @@ function toggleNavigation() { menu.insertBefore(title, menu.children[0]); sidebar.appendChild(menu); + + var sidebarHeight = sidebar.querySelector('ul').getBoundingClientRect().height + 55; + + document.addEventListener('scroll', function() { + if (window.scrollY + sidebarHeight >= main[0].offsetHeight) { + sidebar.style.position = 'absolute'; + sidebar.style.top = (main[0].offsetHeight - sidebarHeight) + 'px'; + } else { + sidebar.style.position = ''; + sidebar.style.top = ''; + } + }); } // remove what is left of the old navigation @@ -45,8 +58,6 @@ function toggleNavigation() { } // main content has-toc - var main = document.querySelectorAll('.main.class'); - if (main[0] && main[0].classList) { main[0].classList.add('has-toc'); } |