Skip to content

Commit db0a622

Browse files
committed
Fixed #11 - The scrollTop is now correct for when there is a hash on the url
1 parent 7459a91 commit db0a622

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

demos/default.html

+1-11
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,7 @@
4747
</head>
4848

4949
<body>
50-
<nav class="navbar">
51-
<div class="navbar-inner">
52-
<div class="container">
53-
<ul class="nav">
54-
<li><a href="/alatriste/1">One</a></li>
55-
<li class="active"><a href="/alatriste/2">Two</li>
56-
<li><a href="/alatriste/3">Three</li>
57-
</ul>
58-
</div>
59-
</div>
60-
</nav>
50+
6151
<a href="https://github.com/gfranko/jquery.tocify.js" target="_blank" id="fork-me"><img style="position: fixed;top: 0; right: 0; border: 0;z-index:999999;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub" alt="Fork me on GitHub"></a>
6252

6353
<div class="container-fluid">

src/javascripts/jquery.tocify.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@
117117
// Adds jQuery event handlers to the newly generated table of contents
118118
self._setEventHandlers();
119119

120-
// The setTimeout allows the correct offset() to be calculated
121-
setTimeout(function() {
120+
// The window onload events allows enough time for the correct offset to be calculated
121+
window.addEventListener("load", function() {
122122

123-
// Set the active TOC item
123+
// Sets the active TOC item
124124
self._setActiveElement();
125125

126-
}, 0);
126+
}, false);
127127

128128
},
129129

src/javascripts/jquery.tocify.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)