Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

right sidebar toc collapse while scrolling #8

Closed
stijnvanhoey opened this issue Sep 9, 2019 · 2 comments · Fixed by #19
Closed

right sidebar toc collapse while scrolling #8

stijnvanhoey opened this issue Sep 9, 2019 · 2 comments · Fixed by #19

Comments

@stijnvanhoey
Copy link
Contributor

As in the documentation website of the previous bootstrap version 3, collapse by default and show lower titles while in certain section, e.g. https://getbootstrap.com/docs/3.4/getting-started/

@stijnvanhoey stijnvanhoey changed the title right sidebabr toc collapse while scrolling right sidebar toc collapse while scrolling Sep 9, 2019
@stijnvanhoey
Copy link
Contributor Author

basic layout to test:

  • extends the active class to the parents of the active a tags of the navbar (template):
<script>
    $(document).ready(function() {
        $('a[href="' + this.location.pathname + '"]')..parents('li,ul').addClass('active');
    });
</script>  
  • add custom class (e.g. toc-section) to the ul sub-elements in the navbar (template)
  • for this class, put display: none by default and as block when active:
ul.toc-section.active {
    display: block;
}

@jorisvandenbossche
Copy link
Member

Bootstrap does this by adding a collapse class to the surrounding div. For that to work, I think we need to divide the list in two parts: main list with level-1 items, and then nested lists with the rest of the levels for each item of the first list (this is what they do with their 4.3 docs for the left sidebar). And then you can let the non-active nested lists be hidden.

That only fully hides or shows after level 1, and not more gradually if a page has more levels of headings. So for that the custom javascript approach above you show might be easier / better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants