implement improved version of go-to-top button with javascript requiring only one click

This commit is contained in:
Axel Kohlmeyer
2025-03-24 00:14:50 -04:00
parent a64863caa6
commit e79fcfb4ef

View File

@ -129,7 +129,7 @@
<div class="wy-grid-for-nav"> <div class="wy-grid-for-nav">
{#- SIDE NAV, TOGGLES ON MOBILE #} {#- SIDE NAV, TOGGLES ON MOBILE #}
<nav data-toggle="wy-nav-shift" class="wy-nav-side"> <nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll"> <div class="wy-side-scroll" id="lammps-navbar">
<div class="wy-side-nav-search" {% if theme_style_nav_header_background %} style="background: {{theme_style_nav_header_background}}" {% endif %}> <div class="wy-side-nav-search" {% if theme_style_nav_header_background %} style="background: {{theme_style_nav_header_background}}" {% endif %}>
{%- block sidebartitle %} {%- block sidebartitle %}
@ -173,15 +173,15 @@
</div> </div>
{%- endblock %} {%- endblock %}
</div> </div>
<!-- <div style="padding: 4px;"> <div style="position: fixed; bottom: 0px; width: 300px; height: 64px; padding: 4px; background-color: #272525; text-align: center">
<center> <button onclick="JumpToTop()" class="fa fa-caret-up" style="color:white; background-color: #272525; border-style: none;" title="Go to top">&nbsp;Go to top</button>
<a href="#sidebar-top-target"><img src="_static/up.png" alt="(Up)"/> Go to top</a>
</center>
</div> </div>
--> <script>
<div style="position: fixed; bottom: 0px; width: 300px; height: 64px; padding: 4px; background-color: #272525; text-align: center"> let navbar = document.getElementById("lammps-navbar");
<a href="#sidebar-top-target" class="fa fa-caret-up" style="color: white"> Go to top</a> function JumpToTop() {
</div> navbar.scrollTop = 0;
}
</script>
</nav> </nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">