Commit 8ea3b1b6 authored by YASUTAKE Kiyoshi's avatar YASUTAKE Kiyoshi
Browse files

Merge pull request #8 from key-amb/develop

Improve: fix sidebar position for single page
parents 540f27bf b54a6903
......@@ -30,6 +30,7 @@
<script src="{{ $baseUrl }}/js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="{{ $baseUrl }}/js/ie10-viewport-bug-workaround.js"></script>
<script src="{{ $baseUrl }}/js/bootie-docs.js"></script>
</body>
</html>
{{ $baseUrl := .Site.BaseURL }}
<div class="col-sm-3 col-sm-offset-1 doc-sidebar">
<div id="sidebar">
<div class="sidebar-module">
<div class="sidebar-toc">
<h4>Table of Contents</h4>
......@@ -17,4 +18,5 @@
{{ end }}
</div>
</div>
</div>
</div><!-- /.doc-sidebar -->
\ No newline at end of file
......@@ -68,6 +68,14 @@ h2, .h2 {
font-size: 80%;
}
/*
* Sidebar
*/
div#sidebar {
position: fixed;
}
/* Sidebar modules for boxing content */
.sidebar-module {
padding: 15px;
......
window.onload = function() {
var headHeight = $("nav").height();
var mainHeight = $("main").height();
var sideHeight = $("#sidebar").height();
var footHeight = $("footer").height();
var totalHeight = headHeight + mainHeight + footHeight;
var w = $(window);
if (sideHeight > 0 && sideHeight < mainHeight) {
$(".doc-sidebar").css("height", mainHeight);
var sideNode = $("#sidebar");
var scrollStart = 0;
var scrollStop = headHeight + mainHeight - sideHeight;
w.scroll(function() {
if (w.scrollTop() <= scrollStart) {
sideNode.css({"position": "fixed"});
} else if (scrollStart < w.scrollTop() && w.scrollTop() < scrollStop) {
sideNode.css({"position": "fixed", "top": headHeight + "px"});
} else if (w.scrollTop() >= scrollStop) {
var topNext
= headHeight - (headHeight + sideHeight)
* (w.scrollTop() - scrollStop) / (totalHeight - scrollStop);
sideNode.css({
"position": "fixed", "top": topNext + "px", "bottom": footHeight + "px"
});
}
});
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment