Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add an (aborted) attempt to have a fixed TOC.

  • Loading branch information...
commit 6376a7c312844e722fe954b35f7750159ab9a228 1 parent e8df609
@romac romac authored
Showing with 51 additions and 2 deletions.
  1. +25 −2 _assets/stylesheet.css
  2. +26 −0 _assets/template.html
View
27 _assets/stylesheet.css
@@ -10,7 +10,7 @@ body
font-family: Georgia, serif;
line-height: 1.6;
width: 720px;
- margin: 0 auto;
+ margin: 0 0 0 400px;
color: #222;
}
@@ -48,11 +48,34 @@ section > section {
padding-bottom: 30px;
}
+#TOC {
+ position: absolute;
+ top: 209px;
+ left: 0;
+ height: auto;
+ overflow: hidden;
+ padding: 20px;
+ font-size: 0.9em;
+ font-family: 'Lato';
+}
+
+#TOC ul {
+ padding-left: 20px;
+}
+
+#TOC > ul > li > ul > li {
+ width: 250px;
+}
+
#TOC > ul > li > ul > li > ul {
display: none;
}
+#TOC > ul > li:first-child {
+ display: none;
+}
+
.highlight {
font-family: Monaco, Menlo, Droid Sans, monospace;
font-size: 0.9em;
-}
+}
View
26 _assets/template.html
@@ -69,6 +69,7 @@ <h4 class="date">$date$</h4>
$if(toc)$
$if(html5)$
<nav id="$idprefix$TOC">
+<h1>Table of contents</h1>
$toc$
</nav>
$else$
@@ -81,5 +82,30 @@ <h4 class="date">$date$</h4>
$for(include-after)$
$include-after$
$endfor$
+<script>
+ window.onscroll = ( function()
+ {
+ return;
+
+ var pinned = false,
+ $toc = document.getElementById( 'TOC' ),
+ offset = 200;
+
+ return function()
+ {
+ if( !pinned && document.body.scrollTop > offset )
+ {
+ $toc.className = 'pinned';
+ pinned = true;
+ }
+ else if( pinned && document.body.scrollTop < offset )
+ {
+ $toc.className = '';
+ pinned = false;
+ }
+ };
+
+ } )();
+</script>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.