Remembering a Sidebar's Scroll Position
Hakim El Hattab tweeted a UX enhancement for a static site with a scrollable navigation sidebar.
The technique: save the scroll offset to localStorage just before the page unloads, then read the value back on load and scroll to it.
The trick is to throw the scroll position into
localStorageright before the page is exited, and when loaded, grab that value and scroll to it.
What's curious is that no flash-of-wrong-scroll-position appears. Perhaps it is related to the paint holding browsers now perform; the author isn't certain.



