From d6feb25e8637844374ccfd1ebebfeb906aed3b93 Mon Sep 17 00:00:00 2001 From: Asiedu13 <58574236+Asiedu13@users.noreply.github.com> Date: Mon, 9 Dec 2019 10:38:41 +0000 Subject: [PATCH 1/3] Scroll button functionality This hides the button when the user is at the top of the webpage but reveal the button when the user scrolls. --- scroll-func.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 scroll-func.js diff --git a/scroll-func.js b/scroll-func.js new file mode 100644 index 0000000000..e027428707 --- /dev/null +++ b/scroll-func.js @@ -0,0 +1,7 @@ +let scrollBtn = document.querySelector(".back-to-top"); +window.addEventListener("scroll", function(){ + let position = window.scrollY; + if(position < 200){ + scrollBtn.style.opacity = "0"; + }else{scrollBtn.style.opacity = "1";} +}) From 7f8103b1e58941a4234d22596e8592775a53513d Mon Sep 17 00:00:00 2001 From: Asiedu13 <58574236+Asiedu13@users.noreply.github.com> Date: Mon, 9 Dec 2019 11:10:38 +0000 Subject: [PATCH 2/3] public lab scroll-to-top #issue 6435 This consists of a function that hides the to-top button on the page and reveal it when the user scrolls From 85288d0847463b829fd059f8e284ec596d888847 Mon Sep 17 00:00:00 2001 From: Asiedu13 <58574236+Asiedu13@users.noreply.github.com> Date: Tue, 10 Dec 2019 02:05:17 +0000 Subject: [PATCH 3/3] indent fixed This is the same scroll-func.js file but with the indentations in a more orderly manner. --- scroll-func.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scroll-func.js b/scroll-func.js index e027428707..0c8f321398 100644 --- a/scroll-func.js +++ b/scroll-func.js @@ -1,7 +1,10 @@ let scrollBtn = document.querySelector(".back-to-top"); window.addEventListener("scroll", function(){ let position = window.scrollY; - if(position < 200){ + if(position < 200){ scrollBtn.style.opacity = "0"; - }else{scrollBtn.style.opacity = "1";} + } + else{ + scrollBtn.style.opacity = "1"; + } })