Skip to content

Commit

Permalink
Fix bug with initial load of ToC always jumping to top
Browse files Browse the repository at this point in the history
  • Loading branch information
lord committed Jul 7, 2017
1 parent 4d3787a commit 5663fb8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/javascripts/app/_toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
;(function () {
'use strict';

var loaded = false;

var debounce = function(func, waitTime) {
var timeout = false;
return function() {
Expand Down Expand Up @@ -57,6 +59,12 @@
}
}

// Catch the initial load case
if (currentTop == scrollOffset && !loaded) {
best = window.location.hash;
loaded = true;
}

var $best = $toc.find("[href='" + best + "']").first();
if (!$best.hasClass("active")) {
// .active is applied to the ToC link we're currently on, and its parent <ul>s selected by tocListSelector
Expand Down

0 comments on commit 5663fb8

Please sign in to comment.