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

Remove react-scrollable-anchor #888

Open
victorlin opened this issue May 31, 2024 · 0 comments
Open

Remove react-scrollable-anchor #888

victorlin opened this issue May 31, 2024 · 0 comments

Comments

@victorlin
Copy link
Member

Context

This was first installed as a NPM dependency then vendored in ab6baf8. It's caused some problems such as #882 and there may be better alternatives.

Potential alternatives

From @ivan-aksamentov in #882 (comment):

  1. For a proper smooth scrolling in modern browsers, I believe that <div id="#foo" /> + <Link href="#foo"/> (or <a href="#foo"/>) + some global CSS:

    html {
      scroll-behavior: smooth;
    }

    (moz, caniuse)

    should do without any packages.

  2. If a more complex imperative smooth scroll is needed, then there are many hook libraries having this functionality (example). Underneath they are typically using something like this, if need to scroll to element's ref:

    ref.current.scrollIntoView({ behavior: 'smooth' })

    or, if need to scroll to coordinates:

    window.scrollTo({
      top: 100,
      left: 100,
      behavior: "smooth",
    });
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

1 participant