Skip to content

Breaks browser's back button #22

Description

@stueja

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);
    });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions