-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PublicLab scroll-to-top issue#6435 #6942
Conversation
This hides the button when the user is at the top of the webpage but reveal the button when the user scrolls.
This consists of a function that hides the to-top button on the page and reveal it when the user scrolls
Thanks for opening this pull request! This space is protected by our Code of Conduct - and we're here to help. |
@@ -0,0 +1,7 @@ | |||
let scrollBtn = document.querySelector(".back-to-top"); | |||
window.addEventListener("scroll", function(){ | |||
let position = window.scrollY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you format this a bit properly?
@Asiedu13 Looks good! Here are a few changes I would suggest, to run this script on all the pages where the scroll-to-top button appears:
Thanks! |
if(position < 200){ | ||
scrollBtn.style.opacity = "0"; | ||
}else{scrollBtn.style.opacity = "1";} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a semicolon at the end of this line, to end the window.addEventListener
function call. Please see my comment on this PR for more general feedback. Thanks!
Hi @Asiedu13 Please close this PR. |
As the person is inactive for more than a month, I am closing the PR. In case you want to push changes please feel free to open a new PR OR reopen this PR and add additional changes to it. |
Fixes #6435
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
rake test
@publiclab/reviewers
for help, in a comment belowIf tests do fail, click on the red
X
to learn why by reading the logs.Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Thanks!