Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-06-28 19:30:51 +0300
committerPhil Hughes <me@iamphill.com>2017-06-28 19:30:51 +0300
commit71fde2a147088398005cd789febe1dbb15d15dae (patch)
tree830f813d4351ba6dc90f7c1fbaa40a01957ad6ea /content
parent4daf1bdbe303f4bbb73583f993ce64e6fc34e14b (diff)
Fixed TOC going under the footer
Diffstat (limited to 'content')
-rw-r--r--content/assets/javascripts/docs.js15
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');
}