by hamasho · 3y ago · 0 comments
Sometimes there's no good result in the first page, or I want to keep searching for more investigation.
When I find a seemingly interesting result after several scrolls and visit the page but find out it's not what I want, I want to go back to the search result and continue. But after browser back, the result is cleared and I have to scroll several times again. Even if I open the result in the different tabs and keep the search result, it may disappear after browser refresh or restart.
Twitter handles this masterfully (or used to)
> or page refresh.
Technically you can use history.replaceState to store, ahem, state on the "current page", so nothing stops you from saving a cursor there to use when loading the content.
The issue with infinite scroll is that very few people know how or care to "make it work correctly"
But once you call history.pushState, the browser is relinquishing control to you. At that point, going “back” only changes the URL, as far as the browser is concerned, and that part is instantaneous.