TylerBarnes / gatsby-plugin-transition-link

A link component for page transitions in gatsby
537 stars 71 forks source link

How to keep hashtags when changing pages? #249

Closed patsa closed 3 years ago

patsa commented 3 years ago

When changing pages through the Anilink component, any anchors within the url get removed, when the targeted page is reached.

I've got the following issue:

I have a footer, that can do 2 things.

  1. If a user is on the same page, as the anchor tag I'm referring to, it should just scroll to the corresponding anchor tag and don't actually trigger any transition whatsoever, because the page doesn't change. In this case I don't use Anilink at all, instead I trigger the scroll event programmatically.
  2. However, if a user is on a different page, a transition should occur, after which a scroll event should be triggered. Therefore I implemented a listener, which checks the current url of the page for any anchors. But after switching pages, the anchors in the url are removed. How to prevent this from happening?
patsa commented 3 years ago

Replication of #209