diff options
Diffstat (limited to '_includes/extensions')
-rw-r--r-- | _includes/extensions/click-to-top.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/_includes/extensions/click-to-top.html b/_includes/extensions/click-to-top.html new file mode 100644 index 0000000..fadd325 --- /dev/null +++ b/_includes/extensions/click-to-top.html @@ -0,0 +1,18 @@ +<div id="click-to-top" class="click-to-top"> + <i class="fa fa-arrow-up"></i> +</div> +<script> + (function () { + const clickToTop = document.getElementById('click-to-top'); + window.addEventListener('scroll', () => { + if (window.scrollY > 100) { + clickToTop.classList.add('show') + }else { + clickToTop.classList.remove('show') + } + }); + clickToTop.addEventListener('click', () => { + window.smoothScrollTo(0); + }); + })(); +</script> |