Closed frederikhors closed 4 years ago
Trying the router after opening this issue I found I cannot "save" my scroll position using back and forward of the browser.
Is there a way to do so?
You may do $: $router.path, window.scrollTo(0, 0)
in your root component to run something when route changes. Or native router.subscribe( _ => window.scrollTo(0, 0))
;
Back and forward cause remounting of corresponding components so scroll position always be on the top. I think it is possible to save scroll position and restore it, but I must be sure whether other unwanted effects won't be.
Just do some investigations about scroll restoration and found that it works out of the box in Chrome, but not in Firefox. So read this https://www.ccdatalab.org/blog/automatic-scroll-restoration-single-page-applications for more info. Look for polyfill for scroll restoration.
In many routers is possible to have a function called after each navigation, useful for actions like:
Is this possible with
tinro
?