Fix scrollspy on link clicking, and # for top of page (#2023)

This commit is contained in:
Erik Demaine 2019-01-15 08:08:41 -05:00 committed by Michael Rose
parent a974e45712
commit 1b7e8335fe
2 changed files with 6 additions and 3 deletions

View file

@ -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);
@ -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

File diff suppressed because one or more lines are too long