vue-router icon indicating copy to clipboard operation
vue-router copied to clipboard

calculated scroll position is incorrect in some browser with animation

Open ytkj opened this issue 7 years ago • 1 comments

Version

2.6.0

Reproduction link

https://jsfiddle.net/ykojima/krqwkfuy/

Steps to reproduce

  1. Run in jsFiddle
  2. Click "Foo" link
  3. 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.

ytkj avatar Jun 21 '17 08:06 ytkj

Thanks for reporting this. I see it's kind of related to #1263 but a bit different

posva avatar Jun 21 '17 15:06 posva