vue-router
vue-router copied to clipboard
calculated scroll position is incorrect in some browser with animation
Version
2.6.0
Reproduction link
https://jsfiddle.net/ykojima/krqwkfuy/
Steps to reproduce
- Run in jsFiddle
- Click "Foo" link
- Click "Go to Bar-2" link
What is expected?
change route to /bar and scroll to "Bar-2" h2 element.
In Chrome, it works fine.
What is actually happening?
change route to /bar, but scroll to the bottom of the page.
This happens in IE11, Firefox, Safari (Mac).
I think this problem cased by:
-
getElementPosition()
is called with the timing at which both leaving route-component and entering route-component exist -
window.scrollTo()
method is called with the timing at which only entered route-component exist
https://github.com/vuejs/vue-router/blob/v2.6.0/src/util/scroll.js#L81
when animation is disabled ( or comment out <transition>
), this problem does not happen.
Thanks for reporting this. I see it's kind of related to #1263 but a bit different