Closed BrittanyIRL closed 4 years ago
The scroll that happens when the sidebar is clicked is lovely, but I'm finding the scroll on load / refresh to be jarring.
The scroll that happens when the sidebar is clicked is lovely, but I'm finding the scroll on load / refresh to be jarring.
What about this? I shortened the animation time. I think it works well?
Page Scroll Implementation
Notion Page
Requirements
Description
ScrollToCurrentSection
replaces the old ScrollToTop component as it is more semantic. Using some hooks to decide when to look for the proper spot to scroll to.useEffect
watches for the pathname update - pathname only updates on page initial load, it has nothing to do with the hash changes in the page. Then useLayoutEffect is watching for hash updates as well as page container height updates (initially) since the playground elements aren't sized until after first paint which makes the initial scrollTo unreliable.Demo
On Refresh or specific hyperlink w/ hash
In docs scroll