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

Router scrollBehavior to.hash fail after #272 #298

Closed
meteorlxy opened this issue Apr 29, 2018 · 3 comments
Closed

Router scrollBehavior to.hash fail after #272 #298

meteorlxy opened this issue Apr 29, 2018 · 3 comments

Comments

@meteorlxy
Copy link
Member

meteorlxy commented Apr 29, 2018

I notice that because of #291. I find the sidebar link's default behavior fails.

Recent commit about that is #272, merged in 6b6d268

meteorlxy added a commit to meteorlxy/vuepress that referenced this issue Apr 29, 2018
@meteorlxy meteorlxy changed the title [Bug] Anchor's default behavior fail after #272 Router scrollBehavior to.hash fail after #272 Apr 29, 2018
@meteorlxy
Copy link
Member Author

meteorlxy commented Apr 29, 2018

if (isActive && this.$route.hash !== anchor.hash) {
this.$router.replace(anchor.hash)
return

vuepress/lib/app/app.js

Lines 56 to 64 in 6b6d268

scrollBehavior: (to, from, saved) => {
if (saved) {
return saved
} else if (to.hash) {
return false
} else {
return { x: 0, y: 0 }
}
}

$router.replace will trigger scrollBehavior, so he set the to.hash branch false, which disabled the default behavior of sidebar links.

Simply set it back to { selector: to.hash } may cause some scroll issue.

@ghost
Copy link

ghost commented Apr 29, 2018

It would be nice to restore the { selector: to.hash } scroll behavior, but prevent it when we're making the $router.replace call while scrolling through the page. With the normal { selector: to.hash }, it will scroll to the anchor when we do the $router.replace while we're scrolling, which leads to some jerky page jumps (especially when scrolling up).

Is there a way to do this? I've looked into it, and I haven't found any obvious solutions.

@ulivz
Copy link
Member

ulivz commented Apr 30, 2018

Fixed at 6081a3d.

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

No branches or pull requests

2 participants