Add Smooth Scrolling

Thanks to Joseph Silber https://stackoverflow.com/a/7717572
This commit is contained in:
Joseph Silber authored and Aditya Telange committed 2020-07-24 23:55:44 +05:30
1 parent 16b98dc8f9
commit 163fa2d3f1
1 file changed
+9
+9
View File
@@ -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>