Skip to content

Commit

Permalink
fix: scroll active sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Oct 20, 2017
1 parent 63d0836 commit a2b8eae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/event/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function scrollTo (el) {
.begin()
}

function highlight () {
function highlight (path) {
if (!enableScrollEvent) return
const sidebar = dom.getNode('.sidebar')
const anchors = dom.findAll('.anchor')
Expand All @@ -45,7 +45,7 @@ function highlight () {
}
}
if (!last) return
const li = nav[last.getAttribute('data-id')]
const li = nav[getNavKey(path, last.getAttribute('data-id'))]

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

Expand Down Expand Up @@ -94,9 +94,9 @@ export function scrollActiveSidebar (router) {
}

if (isMobile) return

dom.off('scroll', highlight)
dom.on('scroll', highlight)
const path = router.getCurrentPath()
dom.off('scroll', () => highlight(path))
dom.on('scroll', () => highlight(path))
dom.on(sidebar, 'mouseover', () => {
hoverOver = true
})
Expand Down

0 comments on commit a2b8eae

Please sign in to comment.