3 ms·
This is a nice and simple solution! Just keep in mind that it'll interact badly with the browser's scroll-to-hash functionality. A full solution is a little mo
by jamesknelson 8y ago
This is a nice and simple solution! Just keep in mind that it'll interact badly with the browser's scroll-to-hash functionality.
A full solution is a little more tricky, and probably involves code on multiple components:
- You'll need something to scroll to the top or the current hash on load
- You'll also need code on <Link> components to check if they link to the current URL/hash, and if they're pointing to the current hash, you'll need to scroll to it on click.
Here's some relevant scroll management code from Navi's components:
- https://github.com/frontarm/navi/blob/master/packages/react-navi/src/View.tsx#L149 https://github.com/frontarm/navi/blob/master/packages/react-...
- https://github.com/frontarm/navi/blob/master/packages/react-navi/src/Link.tsx#L259 https://github.com/frontarm/navi/blob/master/packages/react-...