Skip to content

calculated scroll position is incorrect in some browser with animation #1530

Open
@ytkj

Description

@ytkj

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions