Skip to content

Commit 4c09627

Browse files
achendrickulivz
authored andcommittedMay 24, 2018
feat: allow for disabling of active hash on scroll (#489)
1 parent 0570777 commit 4c09627

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎docs/default-theme-config/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ sidebarDepth: 2
142142
---
143143
```
144144

145+
### Active Header Links
146+
147+
By default, the nested header links and the hash in the URL are updated as the user scrolls to view the different sections of the page. This behavior can be disabled with the following theme config:
148+
149+
``` js
150+
module.exports = {
151+
themeConfig: {
152+
disableActiveHash: true, // boolean
153+
}
154+
}
155+
```
156+
145157
### Sidebar Groups
146158

147159
You can divide sidebar links into multiple groups by using objects:

‎lib/default-theme/Layout.vue

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ export default {
136136
this.setActiveHash()
137137
}, 300),
138138
setActiveHash () {
139+
if (this.$site.themeConfig.disableActiveHash) {
140+
return
141+
}
142+
139143
const sidebarLinks = [].slice.call(document.querySelectorAll('.sidebar-link'))
140144
const anchors = [].slice.call(document.querySelectorAll('.header-anchor'))
141145
.filter(anchor => sidebarLinks.some(sidebarLink => sidebarLink.hash === anchor.hash))

0 commit comments

Comments
 (0)
Please sign in to comment.