rfcs
rfcs copied to clipboard
VueRouter - Allow scrolling other than window
Would using scrollIntoView be an option as a way to solve the first drawback about old browser quirks?
ScrollIntoView does something else afaik - it scrolls the parent of a child to get the child into view, and does not scroll the element itself.
This should work:
if (isObject && typeof shouldScroll.selector === 'string') {
const el = document.querySelector(shouldScroll.selector)
if (el) {
el.scrollIntoView()
}
we'd only need to add additional logic for isPop
It's not just scrolling into view - it's keeping the last position, scrolling element can be huge - thousands of pixels, scrolling to the top of it (or center or any other option) - is not the required behavior, it should be where it was before navigation.
Hmm, yes. Isnt that actually managed by saveScrollPosition
anyway? The position calculated in scrollToPosition
doesnt seem to be used for that.
save scroll position saves it only from the window, which is in some cases not the scroller.
Check out my draft PR for a full example - it saves the new position and uses it on the new element.