-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Smooth scrolling by Links #3318
Comments
Regular |
can you talk me how to added this module in Gatsby and used it? |
Sure! if (typeof window !== 'undefined') {
// Make scroll behavior of internal links smooth
require('smooth-scroll')('a[href*="#"]');
} Every |
thanks, .i don't know how to import this package in my Gatsby project . can you share complete code file? |
thanks, man! |
@kripod Did you try to make back/forth navigation work for anchor links when using |
Having some issue with your code... |
@kriim I did, but unfortunately, I could not make them work as intended. @TomPichaud Please make sure that you are using regular |
Hi also working on a single page site with #hash navigation not using
|
Hey guys, I made an anchor smooth scroll component using browser’s built-in smooth scroll behavior. One caveat is Safari doesn’t yet support it. https://gist.github.com/ryanditjia/f66dd1d0e7dfd678a18dc4a15de8531d Give it a try and let me know if it works for you. Technique adapted from: https://pawelgrzybek.com/page-scroll-in-vanilla-javascript/#a-future-solution-using-scroll-behavior-smooth |
@ryanditjia thanks for the gist! A documentation would be very helpful. |
@ryanditjia I added a comment to your gist. Github dont send any emails for gist comments ... sorry for discussing it here :( |
Don’t worry about it. I stumbled across your comment yesterday when I opened the gist, wouldn’t have known otherwise. Shoot me an email (ryandi.tjia@gmail.com) or open a new issue if you have more questions! |
@kripod thanks your code snippet worked great for my site! I used it to write a small demo with instructions in case it helps anyone in the future. demo code: https://github.com/chrisfitkin/gatsby-smooth-scroll-demo/ |
@kripod and @chrisfitkin - thank you so much! |
Hey all, is it possible to adjust the scroll-speed somehow? |
@EdgarNigel it's in the module docs |
Thank you for this Solution @kripod. But this doesn't work in production. With gatsby build, it says "window" is not available during server-side rendering." |
Are you sure you’ve copied the |
I tried to use this but it didn't work for me! |
Sadly I couldn't make it work when the
Has anyone gone thought this problem? |
I also couldn't make it work with the |
Today, I tried my best to implement anchor-based smooth scrolling for a single-page application, but failed after multiple tries. I wanted to add smooth scrolling for my
Link
elements (from gatsby-link) using the following libraries:I also tried some React-targeted alternatives, but they didn’t work either. Unfortunately, I could not find an answer to this problem, so I would highly appreciate any kind of assistance.
The text was updated successfully, but these errors were encountered: