Skip to content

Commit a2b8eae

Browse files
committed
fix: scroll active sidebar
1 parent 63d0836 commit a2b8eae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/core/event/scroll.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function scrollTo (el) {
2424
.begin()
2525
}
2626

27-
function highlight () {
27+
function highlight (path) {
2828
if (!enableScrollEvent) return
2929
const sidebar = dom.getNode('.sidebar')
3030
const anchors = dom.findAll('.anchor')
@@ -45,7 +45,7 @@ function highlight () {
4545
}
4646
}
4747
if (!last) return
48-
const li = nav[last.getAttribute('data-id')]
48+
const li = nav[getNavKey(path, last.getAttribute('data-id'))]
4949

5050
if (!li || li === active) return
5151

@@ -94,9 +94,9 @@ export function scrollActiveSidebar (router) {
9494
}
9595

9696
if (isMobile) return
97-
98-
dom.off('scroll', highlight)
99-
dom.on('scroll', highlight)
97+
const path = router.getCurrentPath()
98+
dom.off('scroll', () => highlight(path))
99+
dom.on('scroll', () => highlight(path))
100100
dom.on(sidebar, 'mouseover', () => {
101101
hoverOver = true
102102
})

0 commit comments

Comments
 (0)