AlexxNB / tinro

Highly declarative, tiny, dependency free router for Svelte's web applications.
MIT License
669 stars 30 forks source link

Maintain previous scroll position when navigating back #92

Open jamauro opened 2 years ago

jamauro commented 2 years ago

When I navigate to a new route and then back, it would be nice if the page was at my previous scroll position so that I don't have to scroll down from the top.

I saw your note Back and forward cause remounting of corresponding components so scroll position always be on the top. from https://github.com/AlexxNB/tinro/issues/3#issuecomment-620520511. I tried the scroll restoration polyfill and it isn't working for me. Would love to see tinro support this instead of hacking together something on my end that I'm sure wouldn't be as good of a solution. :)

AlexxNB commented 2 years ago

Browser leave the scroll position if your elements render rapidly. But other case you should restore scroll yourself. I don't want implement this feature in tinro, because it is not universal.