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

Breaks browser's back button #22

Open
stueja opened this issue Oct 4, 2016 · 2 comments
Open

Breaks browser's back button #22

stueja opened this issue Oct 4, 2016 · 2 comments

Comments

@stueja
Copy link

stueja commented Oct 4, 2016

I found out that scrolling to an anchor works wonderfully, however breaking the browser's back button's functionality (Chromium, Firefox, Safari Mobile).
After commenting out the below, the back button works, however not scrolling smoothly.

I was trying onpopstate and different onpushstate variants to have it scroll smoothly to the top again, upon clicking the back button, but wasn't able to do so. If you have an idea, I'd appreciate it.

  const complete = (hash, coordinates) => {
    //history.pushState(null, null, hash);
    root.scrollTop = coordinates.get("start") + coordinates.get("delta");
  };

  const attachHandler = (links, index) => {
    const link = links.item(index);
    link.addEventListener("click", event => {
      //event.preventDefault();

      scroll(link);
    });
@GabrielPerry
Copy link

Hello... I'm experiencing the same issue and trying to figure out a solution. I'm bummed no one's responded to you on this. I'm still plugging away at it. If I come up with a solution, I'll post it here.

@dziku86
Copy link

dziku86 commented Apr 22, 2020

That's expected behavior when you preventDefault() on anchor links.
Use history.pushState() to update url.

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

3 participants