Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Conversation

Asiedu13
Copy link
Contributor

@Asiedu13 Asiedu13 commented Dec 9, 2019

Fixes #6435

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If 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!

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
@welcome
Copy link

welcome bot commented Dec 9, 2019

Thanks for opening this pull request! This space is protected by our Code of Conduct - and we're here to help.
Dangerbot will test out your code and reply in a bit with some pointers and requests.
Also please refer here for installation help 💿
There may be some errors, but don't worry! We'll work through them with you! 👍🎉😄
It would be great if you can tell us your Twitter handle so we can thank you properly?

@@ -0,0 +1,7 @@
let scrollBtn = document.querySelector(".back-to-top");
window.addEventListener("scroll", function(){
let position = window.scrollY;
Copy link
Contributor

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?

@anthony-zhou
Copy link
Member

@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:

  1. To fit the current filename conventions, rename scroll-func.js to scroll_func.js.
  2. Move the file scroll_func.js out of the root folder and into app/assets/javascripts.
  3. Include the Javascript in the default page layout by adding a //= require scroll-func.js statement in application.js, in the APPLICATION SCRIPTS section
  4. (optional) Consider using CSS to add an opacity transition to the scroll-to-top button, so that it fades in and fades out.

Thanks!

if(position < 200){
scrollBtn.style.opacity = "0";
}else{scrollBtn.style.opacity = "1";}
})
Copy link
Member

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!

@anthony-zhou
Copy link
Member

@Asiedu13 Looks like PR #6944 is a more recent version of this one, so you can close this pull request.

@CodeSarthak
Copy link
Collaborator

Hi @Asiedu13 Please close this PR.

@SidharthBansal
Copy link
Member

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.
Thanks for contributing on Public Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove "scroll to top" arrow key
5 participants