fix: scroll active sidebar
This commit is contained in:
parent
63d08369f6
commit
a2b8eae8c4
1 changed files with 5 additions and 5 deletions
|
|
@ -24,7 +24,7 @@ function scrollTo (el) {
|
||||||
.begin()
|
.begin()
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlight () {
|
function highlight (path) {
|
||||||
if (!enableScrollEvent) return
|
if (!enableScrollEvent) return
|
||||||
const sidebar = dom.getNode('.sidebar')
|
const sidebar = dom.getNode('.sidebar')
|
||||||
const anchors = dom.findAll('.anchor')
|
const anchors = dom.findAll('.anchor')
|
||||||
|
|
@ -45,7 +45,7 @@ function highlight () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!last) return
|
if (!last) return
|
||||||
const li = nav[last.getAttribute('data-id')]
|
const li = nav[getNavKey(path, last.getAttribute('data-id'))]
|
||||||
|
|
||||||
if (!li || li === active) return
|
if (!li || li === active) return
|
||||||
|
|
||||||
|
|
@ -94,9 +94,9 @@ export function scrollActiveSidebar (router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile) return
|
if (isMobile) return
|
||||||
|
const path = router.getCurrentPath()
|
||||||
dom.off('scroll', highlight)
|
dom.off('scroll', () => highlight(path))
|
||||||
dom.on('scroll', highlight)
|
dom.on('scroll', () => highlight(path))
|
||||||
dom.on(sidebar, 'mouseover', () => {
|
dom.on(sidebar, 'mouseover', () => {
|
||||||
hoverOver = true
|
hoverOver = true
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue