Skip to content

Commit

Permalink
Scroll top fix @publiclab (publiclab#6944)
Browse files Browse the repository at this point in the history
* 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.

* 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

* indent fixed

This is the same scroll-func.js file but with the indentations in a more orderly manner.
  • Loading branch information
Asiedu13 authored and Vinit Shahdeo committed Feb 1, 2020
1 parent 9b806c7 commit 380ee9b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scroll-func.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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";
}
})

0 comments on commit 380ee9b

Please sign in to comment.