Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scroll): use manual scrollRestoration with scrollBehavior #1814

Merged
merged 3 commits into from
May 9, 2020

Conversation

Dzinlife
Copy link
Contributor

@Dzinlife Dzinlife commented Oct 15, 2017

Browser default to perform a scroll when popstate happens which cause a glitch especially when using vue-router async scroll.

window.history.scrollRestoration = 'manual';

Fix by adding this line.

@posva
Copy link
Member

posva commented Oct 15, 2017

Could you provide a repro illustrating the problem, please? You can use this fiddle or provide an HTML page

@Dzinlife
Copy link
Contributor Author

Dzinlife commented Oct 15, 2017

http://jsfiddle.net/Lfeg5dtw/

I use a router transition so you can see it clearly.
Scroll to the bottom of /Foo and click the back button, the browser will perform an unexpected scroll.

@yyx990803
Copy link
Member

You can simply set this up in your own code - forcing it to always manual seems less flexible.

@yyx990803 yyx990803 closed this Oct 23, 2017
@yyx990803
Copy link
Member

On another thought - maybe this is a good default to have.

@kchq
Copy link

kchq commented Oct 24, 2019

Let's get this bad boy in here, eh?

src/util/scroll.js Outdated Show resolved Hide resolved
@posva posva changed the title Prevent browser scroll behavior on History popstate feat(scroll): use manual scrollRestoration with scrollBehavior May 9, 2020
@posva posva merged commit 1261363 into vuejs:dev May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants