Add Smooth Scrolling

Thanks to Joseph Silber https://stackoverflow.com/a/7717572
This commit is contained in:
Joseph Silber 2020-07-24 23:55:44 +05:30 committed by Aditya Telange
parent 16b98dc8f9
commit 163fa2d3f1

View File

@ -10,4 +10,13 @@
<script src="{{ $highlight.Permalink }}" integrity="{{ $highlight.Data.Integrity }}"></script> <script src="{{ $highlight.Permalink }}" integrity="{{ $highlight.Data.Integrity }}"></script>
<script> <script>
hljs.initHighlightingOnLoad(); hljs.initHighlightingOnLoad();
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth"
});
});
});
</script> </script>