pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/mkdocs/mkdocs/discussions/4025

" href="https://github.githubassets.com/assets/github-3e4b462972b5430c.css" /> How to scroll to the active page in navigation drawer when opening it · mkdocs/mkdocs · Discussion #4025 · GitHub
Skip to content
Discussion options

You must be logged in to vote

This is a common UX issue with MkDocs (and Material for MkDocs) when the navigation drawer opens on small screens. The default behavior doesn't auto-scroll to the active item.

You can fix this with a small JavaScript snippet. Add it to your docs/javascripts/extra.js:

document.addEventListener("DOMContentLoaded", function () {
  var toggle = document.querySelector('[data-md-toggle="drawer"]');
  if (toggle) {
    toggle.addEventListener("change", function () {
      if (this.checked) {
        // Small delay to let the drawer animate open
        setTimeout(function () {
          var activeLink = document.querySelector(
            ".md-sidebar--primary .md-nav__link--active"
          );

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by honeyedoasis
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy