Skip to content

Commit

Permalink
smooth back to top animation
Browse files Browse the repository at this point in the history
  • Loading branch information
semanticdata committed Oct 16, 2024
1 parent 748bcc4 commit b94ddae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions sass/_pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

&:hover {
opacity: 1;
cursor: pointer;
}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1 class="post-title">{{ page.title }}</h1>
{% if page.higher -%}
<a href="{{ page.higher.permalink | safe }}" class="left arrow">&#8592;</a>
{%- endif %}
<a href="#" class="top">Top</a>
{% include "partials/back-to-top.html" %}
{% if page.lower -%}
<a href="{{ page.lower.permalink | safe }}" class="right arrow">&#8594;</a>
{%- endif %}
Expand Down
6 changes: 6 additions & 0 deletions templates/partials/back-to-top.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<a class="top" id="goToTopBtn" onclick="goToTop()" title="Go to top">Top</a>
<script>
function goToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
</script>

0 comments on commit b94ddae

Please sign in to comment.