-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add Scroll to Top button #50
feat: add Scroll to Top button #50
Conversation
…ering in browser yet
…thod is causing it to not work
… scrollTo still not working.
… scrollTop currently returning 0.
… and works as expected
…king as expected.
…tested for light/dark mode
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
we're talking right now so todo will post actual thoughts hello hi
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.
This is looking great, thanks! ✨ - it works, it looks nice, and it even has some snazzy horizontal sliding. Just requesting a couple UI fixups and some code things.
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.
💯 this is great, thanks!
I'll post followup issues after. Feel free to get started on them if you want in the meantime, but no rush.
Really excited about this - thanks @jrachelr! 🚀
@all-contributors please add @JoshuaKGoldberg for maintenance.
|
I've updated the pull request to add @JoshuaKGoldberg! 🎉 I couldn't determine any contributions to add, did you specify any contributions? |
@allcontributors add @jrachelr for feat |
I couldn't determine any contributions to add, did you specify any contributions? |
@allcontributors add @jrachelr for code |
I've put up a pull request to add @jrachelr! 🎉 |
Adds @jrachelr as a contributor for code. This was requested by JoshuaKGoldberg [in this comment](#50 (comment)) --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
@allcontributors add @jrachelr for design |
I've put up a pull request to add @jrachelr! 🎉 |
Adds @jrachelr as a contributor for design. This was requested by JoshuaKGoldberg [in this comment](#50 (comment)) --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
PR Checklist
status: accepting prs
Overview
Previously if a search returned multiple pages of results the user needed to manually scroll to return to the search form.
These changes add a scroll to top button component to improve UI.
How
ScrollButton
works:setState
hook for[visible, setVisible]
is set tofalse
document.body.addEventListener("scroll", toggleVisible, { passive: true })
listens for the scroll event and sets the passive option to true to improve performance.toggleVisible
function referencesdocument.body
using the built inscrollTop
property and updates state tovisible
after scrolling >100 pixels, rendering the button in the DOMscrollToTop
function uses the built in browser methodscrollTo
to scroll to thetop: 0
coordinate ofdocument.body
.scrollToTop
is called when the button is clicked by the user with aonClick
event handler