Skip to content

Commit

Permalink
Fix bug: click the TOP button didn't scroll back to top
Browse files Browse the repository at this point in the history
  • Loading branch information
ngzhio committed Jul 3, 2020
1 parent 5cc8056 commit 3498003
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion _layouts/archive-taxonomies.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,14 @@ <h2 id="{{ slugified_taxonomy_name }}">
</li>
{%- endfor -%}
</ul>
<a href="#" class="back-to-top">Top &#8648;</a>
<a href="#" onclick="backToTop()" class="back-to-top">Top &#8648;</a>
{%- endif -%}
{%- endfor -%}
{%- endfor -%}

<script>
function backToTop() {
const main = document.getElementById("site-main");
main.scrollTop = 0;
}
</script>
9 changes: 8 additions & 1 deletion _layouts/archive-years.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,12 @@ <h2 id="{{ taxonomy.name }}">
</li>
{%- endfor -%}
</ul>
<a href="#" class="back-to-top">Top &#8648;</a>
<a href="#" onclick="backToTop()" class="back-to-top">Top &#8648;</a>
{%- endfor -%}

<script>
function backToTop() {
const main = document.getElementById("site-main");
main.scrollTop = 0;
}
</script>
2 changes: 1 addition & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<aside class="site-sidebar" id="site-sidebar">
{% include sidebar.html %}
</aside>
<main class="site-main" aria-label="Content">
<main class="site-main" id="site-main" aria-label="Content">
{{ content }}
<footer class="site-footer">
{% include footer.html %}
Expand Down

0 comments on commit 3498003

Please sign in to comment.