vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.95k stars 1.19k forks source link

Ability to pass a custom function for computeScrollPosition #2402

Closed preetmishra closed 1 week ago

preetmishra commented 1 week ago

What problem is this solving

Due to the way our HTML layout is set up, the scrollbar appears on an element several levels deeper rather than on the window itself, breaking the intended functionality. The scroll position is never restored because of the incorrect values in the savedPosition property.

export const computeScrollPosition = (): _ScrollPositionNormalized => ({
  left: window.scrollX,
  top: window.scrollY,
})

Proposed solution

We’d like the option to pass a custom function that calculates the top value based on another element's scrollTop in the HTML. We're open to other workarounds and are happy to submit a PR with the proposed solution as well.

Describe alternatives you've considered

No response

posva commented 1 week ago

Closing in favor of #2403 which was in the board but not visible in issues

preetmishra commented 1 week ago

Thanks, @posva! Any general timeline about how much time it could take? Happy to submit a PR too!