router icon indicating copy to clipboard operation
router copied to clipboard

Controlling what scroll position is saved

Open posva opened this issue 1 year ago • 0 comments

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 beforeunload event, which is crucial.
  • It should be possible to save the scroll position without a native state (abstract history needs state?)

posva avatar Nov 13 '24 13:11 posva