Skip to main content Skip to secondary navigation Accessibility Feedback

Updates to Smooth Scroll

Last week I released version 10 of Smooth Scroll, easily my most popular open source project.

Version 10 brings with it a few meaningful changes to make it more accessible and resilient:

  • Instead of preventing default behaviors on click, it now temporarily removes the id from the target element to prevent scroll jumping, then adds it back after the hashchange. This provides built in browser history and forward/backward button support, instead of having to recreate that stuff with JS.
  • This new approach also allows for animated scrolling on page load, out of the box (an often asked for feature).
  • animateScroll() now supports scrolling to a number, not just an element, for greater developer flexibility.
  • More articles on...
  • Code

Have any questions or comments about this post? Email me at chris@gomakethings.com or contact me on Twitter at @ChrisFerdinandi.

Get the Weekly Digest