router
router copied to clipboard
Controlling what scroll position is saved
Controlling what scroll position is saved
RFC at https://github.com/vuejs/rfcs/pull/38 is not flexible enough: what about named views, what about scrolling multiple elements in the page.
A better option could be customising the computation of the scrollPosition saved in the history state as well as the restoration of that given scrollPosition. This would be a replacement for current scrollBehavior option and maybe we could internally refactor ours to do that
- https://github.com/vuejs/rfcs/pull/38
Another possibility is to move this to an official plugin similar to https://github.com/antfu/vue-router-better-scroller
Other things to take into account:
- Allow to manually save the scroll position (https://github.com/vuejs/router/discussions/2589). Useful to save the position after scrolling so reloading will see the correct position. This avoids using
beforeunloadevent, which is crucial. - It should be possible to save the scroll position without a native state (abstract history needs state?)