Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

phouri
Copy link

@phouri phouri commented May 23, 2019

@pimlie
Copy link

pimlie commented Jun 26, 2019

Would using scrollIntoView be an option as a way to solve the first drawback about old browser quirks?

@phouri
Copy link
Author

phouri commented Jun 26, 2019

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.

@pimlie
Copy link

pimlie commented Jun 26, 2019

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

@phouri
Copy link
Author

phouri commented Jun 26, 2019

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.

@pimlie
Copy link

pimlie commented Jun 26, 2019

Hmm, yes. Isnt that actually managed by saveScrollPosition anyway? The position calculated in scrollToPosition doesnt seem to be used for that.

@phouri
Copy link
Author

phouri commented Jun 26, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants