Skip to content

Commit 60de032

Browse files
author
Manuel Mujica
authored
Merge pull request #8 from bit-docs/scroll-hash
Scroll to active hash url on load
2 parents a7d5574 + 73230ae commit 60de032

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"homepage": "https://github.com/bit-docs/bit-docs-docjs-theme#readme",
2727
"devDependencies": {
2828
"bit-docs-generate-html": "^0.3.3",
29-
"bit-docs-html-toc": "^0.2.1"
29+
"bit-docs-html-toc": "^0.4.0"
3030
},
3131
"dependencies": {
3232
"jquery": "^3.1.1"

static/docjs.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ $(function() {
2222
$el.prepend(anchorTemplate({ id: id }));
2323
});
2424

25+
if (window.location.hash.length) {
26+
var id = window.location.hash.replace("#", "");
27+
var anchor = document.getElementById(id);
28+
29+
if (anchor) {
30+
anchor.scrollIntoView(true);
31+
}
32+
}
33+
2534
function collectHeadings() {
2635
return $(".content .comment h2, .content .comment h3");
2736
}

0 commit comments

Comments
 (0)