on master help sign in
Adding disabled summary header opening
commit4f2cb08ef60a9d0fd4dc7f76eba0b90cc5567ce5 authorMatilde Park <matilde@tlon.io> dateTue 10 Sep 2019, 16:31 (7 years ago) parentcd2b282
2 files changed+18−2
static/scripts.js+17−1 templates/page_indiced.html+1−1
static/scripts.js+17−1
@@ -367,6 +367,22 @@ window.addEventListener("scroll", event => {
367367 }
368368 });
369369
370−});
370+ // this is honestly weird UX when selecting a link,
371+ // as every header flies open as you scroll.
372+ // for later discussion and experimentation --
373+ // may just need debouncing.
374+ // Also still working out the logic for closing other summary
375+ // headers as you scroll.
376+
377+// headers.forEach(summary => {
378+// let thisH2 = document.querySelector("h2#" + CSS.escape(summary.id));
379+// if (
380+// (thisH2.offsetTop <= fromTop) &&
381+// (thisH2.offsetTop + thisH2.offsetHeight > fromTop)
382+// ) {
383+// summary.parentElement.open = true;
384+// }
385+// })
386+//});
371387
372388}
templates/page_indiced.html+1−1
@@ -36,7 +36,7 @@
3636
3737{% for h2 in toc %}
3838{% if h2.children %}
39−<details class="page-indiced"><summary>{{ h2.title }}</summary>
39+<details class="page-indiced"><summary id={{h2.id}}>{{ h2.title }}</summary>
4040 {% for h3 in h2.children %}
4141 <li class="ml3 mv1"><a href="{{h3.permalink | safe}}">{{h3.title}}</a></li>
4242 {% endfor %}