From 4dfc50dae96d477e460001249efac413b85045a5 Mon Sep 17 00:00:00 2001 From: Bhavy_Zala Date: Fri, 31 May 2024 15:59:23 +0530 Subject: [PATCH] Scroll to top button added --- assets/js/scroll.js | 54 ++++++++++++++++++++++----------------------- index.html | 8 +++---- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/assets/js/scroll.js b/assets/js/scroll.js index ca97264698..55e46cdad8 100644 --- a/assets/js/scroll.js +++ b/assets/js/scroll.js @@ -1,33 +1,33 @@ -// let calcScrollValue = () => { -// let scrollProg = document.getElementById("progress"); -// let pos = document.documentElement.scrollTop; -// let calcHeight = -// document.documentElement.scrollHeight - -// document.documentElement.clientHeight; -// let scrollValue = Math.round((pos * 100) / calcHeight); -// if (pos > 100) { -// scrollProg.style.display = "grid"; -// } else { -// scrollProg.style.display = "none"; -// } -// scrollProg.addEventListener("click", () => { -// document.documentElement.scrollTop = 0; -// }); -// scrollProg.style.background = `conic-gradient(#6862e8 ${scrollValue}%, #d499de ${scrollValue}%)`; -// }; +let calcScrollValue = () => { + let scrollProg = document.getElementById("progress"); + let pos = document.documentElement.scrollTop; + let calcHeight = + document.documentElement.scrollHeight - + document.documentElement.clientHeight; + let scrollValue = Math.round((pos * 100) / calcHeight); + if (pos > 100) { + scrollProg.style.display = "grid"; + } else { + scrollProg.style.display = "none"; + } + scrollProg.addEventListener("click", () => { + document.documentElement.scrollTop = 0; + }); + scrollProg.style.background = `conic-gradient(#6862e8 ${scrollValue}%, #d499de ${scrollValue}%)`; + }; -// window.addEventListener('scroll', function() { -// var scrollToTopButton = document.getElementById('progress'); -// if (window.pageYOffset > 200) { -// scrollToTopButton.style.display = 'block'; -// } else { -// scrollToTopButton.style.display = 'none'; -// } -// }); + window.addEventListener('scroll', function() { + var scrollToTopButton = document.getElementById('progress'); + if (window.pageYOffset > 200) { + scrollToTopButton.style.display = 'block'; + } else { + scrollToTopButton.style.display = 'none'; + } + }); -// window.onscroll = calcScrollValue; -// window.onload = calcScrollValue; + window.onscroll = calcScrollValue; + window.onload = calcScrollValue; const filled = document.querySelector(".filled"); diff --git a/index.html b/index.html index 9e168f82e8..48a7375ec6 100644 --- a/index.html +++ b/index.html @@ -373,14 +373,14 @@

Our Valuable Contributors - + - +