npm gatsby 0.12.32
New browser API to allow overriding of scrolling behavior

latest releases: 5.15.0-next.0, 5.14.0, 5.13.7...
7 years ago

On old skool web sites, browsers maintain your scroll position for you as you navigate between pages and back. So if you scroll down on a page, click to another link, and then click back — your scroll position on the original page will be set to where you were before clicking away.

But as Gatsby turns your website into a single-page-app, this default browser handling of scroll position has to be emulated. For that we use @taion's great library https://github.com/taion/react-router-scroll

In Gatsby's web-entry.js file where React Router is setup and we do React's rendering to DOM, we have a function which determines whether or not to use the remembered scroll position. For the vast majority of websites, the behavior specified there is correct but occasionally you'll be building something special and will want to use different logic.

To enable customizing scroll behavior, @Rusta, in #663, added a new lifecycle API for overriding the default scroll behavior.

Thanks @Rusta!

Don't miss a new gatsby release

NewReleases is sending notifications on new releases.