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(theme-default): subtitle automatically appears in the view when it overflows the visual area #698

Merged
merged 8 commits into from Mar 31, 2022

Conversation

zh-lx
Copy link
Contributor

@zh-lx zh-lx commented Feb 17, 2022

close #658
When I scroll markdown content, I need to swipe sidebar to see the corresponding subtitle if the current subtitle is too far behind:
image

This PR will realize the function that the page content scrolls, if the active subtitle overflows the visual area, it will automatically scroll to the visual area. The effect is shown in GIF below:
auto-scroll

@Mister-Hope
Copy link
Member

Mister-Hope commented Feb 20, 2022

Wait... Does it work with sidebar group or even nested sidebar group? Since each sidebar group will have a sideLinks as children, there might be mutiple components in a single sideabr

@zh-lx
Copy link
Contributor Author

zh-lx commented Feb 20, 2022

Wait... Does it work with sidebar group or even nested sidebar group? Since each sidebar group will have a sideLinks as children, there might be mutiple components in a single sideabr

Yes, I have tested the case, there might are many active sidebars but only one of them whose href is completely match both path and hash of the page. And the code will find this one and let it scrollIntoView.

const activeSidebarItem = document.querySelector(
  `[href="${router.currentRoute.value.path}${router.currentRoute.value.hash}"]`
)

@zh-lx zh-lx requested a review from meteorlxy February 25, 2022 06:37
@meteorlxy meteorlxy merged commit 08b9e9a into vuepress:main Mar 31, 2022
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

Successfully merging this pull request may close these issues.

[Feature request]: subtitle automatically appears in the view
3 participants