diff --git a/docs/extra.js b/docs/extra.js new file mode 100644 index 0000000000..9fa715a04d --- /dev/null +++ b/docs/extra.js @@ -0,0 +1,22 @@ +document$.subscribe(function () { + // Stop mkdocs-material from hiding the version selector when scrolling down; + // this is done by removing the --active class when mkdocs-material adds it. + // (--active = scrolled down) + + const title = document.querySelector('*[data-md-component="header-title"]'); + + const observer = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + if (mutation.attributeName === "class") { + const classList = title.className.split(" "); + classList.forEach((className) => { + if (className.endsWith("--active")) { + title.classList.remove(className); + } + }); + } + }); + }); + + observer.observe(title, { attributes: true }); +}); diff --git a/mkdocs.yml b/mkdocs.yml index 2e85e10fac..7d3c708868 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -84,6 +84,9 @@ markdown_extensions: emoji_index: !!python/name:material.extensions.emoji.twemoji emoji_generator: !!python/name:material.extensions.emoji.to_svg +extra_javascript: + - extra.js + # This lists all the files that become part of the documentation nav: - 'Home': 'index.md'