summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Silber <contact@josephsilber.com>2020-07-24 23:55:44 +0530
committerAditya Telange <21258296+adityatelange@users.noreply.github.com>2020-07-24 23:55:44 +0530
commit163fa2d3f1a1c9bdb99052b3630dfa8d2b91810b (patch)
tree0dd527f3647c3a0b76c2a3af51a13b8f257b8ebe
parent16b98dc8f9ca0adfb9a8dbd3062c378ee2f330ae (diff)
Add Smooth Scrolling
Thanks to Joseph Silber https://stackoverflow.com/a/7717572
-rw-r--r--layouts/partials/footer.html9
1 files changed, 9 insertions, 0 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 38f6d30..efab5bb 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -10,4 +10,13 @@
<script src="{{ $highlight.Permalink }}" integrity="{{ $highlight.Data.Integrity }}"></script>
<script>
hljs.initHighlightingOnLoad();
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener("click", function (e) {
+ e.preventDefault();
+
+ document.querySelector(this.getAttribute("href")).scrollIntoView({
+ behavior: "smooth"
+ });
+ });
+ });
</script> \ No newline at end of file