From 5663fb8b4f3019e848736c76c0752d67643924e1 Mon Sep 17 00:00:00 2001 From: Robert Lord Date: Thu, 6 Jul 2017 23:32:22 -0700 Subject: [PATCH] Fix bug with initial load of ToC always jumping to top --- source/javascripts/app/_toc.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/javascripts/app/_toc.js b/source/javascripts/app/_toc.js index 17e785c..bb651b0 100644 --- a/source/javascripts/app/_toc.js +++ b/source/javascripts/app/_toc.js @@ -3,6 +3,8 @@ ;(function () { 'use strict'; + var loaded = false; + var debounce = function(func, waitTime) { var timeout = false; return function() { @@ -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