From a2b8eae8c40a094d57a43209e827f12a2a076646 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Fri, 20 Oct 2017 12:54:27 +0800 Subject: [PATCH] fix: scroll active sidebar --- src/core/event/scroll.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/event/scroll.js b/src/core/event/scroll.js index 9aa20635..be64d968 100644 --- a/src/core/event/scroll.js +++ b/src/core/event/scroll.js @@ -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') @@ -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 @@ -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 })