From 68667519388f4cb03ebcf62eb0aab258ecafde4b Mon Sep 17 00:00:00 2001 From: Thomas Thomassen Date: Wed, 27 Feb 2019 17:49:30 +0100 Subject: [PATCH] Workaround for broken Browser Back for anchors. Fixes #1071 --- templates/default/fulldoc/html/js/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/templates/default/fulldoc/html/js/app.js b/templates/default/fulldoc/html/js/app.js index fecf69db3..368f44a94 100644 --- a/templates/default/fulldoc/html/js/app.js +++ b/templates/default/fulldoc/html/js/app.js @@ -275,6 +275,16 @@ function mainFocus() { setTimeout(function() { $('#main').focus(); }, 10); } +function navigationChange() { + // This works around the broken anchor navigation with the YARD template. + window.onpopstate = function() { + var hash = window.location.hash; + if (hash !== '' && $(hash)[0]) { + $(hash)[0].scrollIntoView(); + } + }; +} + $(document).ready(function() { navResizer(); navExpander(); @@ -287,6 +297,7 @@ $(document).ready(function() { constantSummaryToggle(); generateTOC(); mainFocus(); + navigationChange(); }); })();