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

Jump to top when using <Link> #13

Open
mdings opened this issue Jan 27, 2020 · 3 comments
Open

Jump to top when using <Link> #13

mdings opened this issue Jan 27, 2020 · 3 comments

Comments

@mdings
Copy link
Contributor

mdings commented Jan 27, 2020

When building links with the builtin Link-component I notice that the page doesn't automatically scroll back to the top when rendered. Is there an action or effect that we can overwrite to do something like document.scrollTop = '0px'?

@mdings
Copy link
Contributor Author

mdings commented Feb 6, 2020

I fixed this now using a navigation subscriber with a location.href mutation observer. However, now the page jumps to the top on every new page vies. Also when using the back-button which is not intended behaviour. Do you know of a more robust way to implement this?

Oh, btw: I just launched my site using Hyperstatic 🎉. It is hosted in Netlify as well: https://www.meetsoil.com (In Dutch for now only..)

@loteoo
Copy link
Owner

loteoo commented Feb 8, 2020

Hey @mdings !! Thanks for creating this issue! This is something I had not thought of.

Sorry for the delayed response.

I made the changes here, do you have any comments on them?
#15

Also, WOW that's a beautiful website. So glad someone experienced is using hyperstatic for it's website :)

Let me know of any ideas / improvements you have in mind!!!

@mdings
Copy link
Contributor Author

mdings commented Feb 11, 2020

Hey @loteoo,

Sorry for the delayed response

That's alright. Thanks for getting back to this. I've seen the PR and it's looking good for what I want to achieve. However, this might not be the case for other people. Can we make this functionality a bit more robust, so that we can override it when needed? With this piece of code the page will also scroll back to the top when hitting the back-button. Maybe you can add an API to the source that let's us overwrite pieces from the source. In the end, that is what adds the flexibility in my opinion.

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

No branches or pull requests

2 participants