Skip to content

Commit

Permalink
Fix scrollspy on link clicking, and # for top of page (#2023)
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine authored and mmistakes committed Jan 15, 2019
1 parent a974e45 commit 1b7e833
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions assets/js/_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ $(document).ready(function() {
$(window).scroll(jQuery.throttle(250, function() {
// Don't run while smooth scrolling (from clicking on a link).
if (smoothScrolling) return;
var scrollTop = $(window).scrollTop() + 20; // 20 = offset
var scrollTop = $(window).scrollTop() + 20 + 1; // 20 = offset
var links = [];
$("nav.toc a").each(function() {
var link = $(this);
Expand All @@ -106,9 +106,12 @@ $(document).ready(function() {
if (links[i].href !== location.hash) {
history.replaceState(null, null, links[i].href);
}
break;
return;
}
}
if ('#' !== location.hash) {
history.replaceState(null, null, '#');
}
}));

// add lightbox class to all image links
Expand Down
Loading

0 comments on commit 1b7e833

Please sign in to comment.