From 1c6d9538a300d9db80655ae59f0a59e14f865bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 4 Sep 2021 11:09:38 +0200 Subject: [PATCH] menu: scroll active item into view #79 --- static/js/relearn.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/static/js/relearn.js b/static/js/relearn.js index aa3003e892..f2afdf1217 100644 --- a/static/js/relearn.js +++ b/static/js/relearn.js @@ -111,6 +111,17 @@ function initMermaid() { } } +function scrollToActiveMenu() { + window.setTimeout(function(){ + var e = $("#sidebar ul.topics li.active")[0]; + if( e.scrollIntoView ){ + e.scrollIntoView({ + block: 'center', + }); + } + }, 200); +} + // Get Parameters from some url var getUrlParameter = function getUrlParameter(sPageURL) { var url = sPageURL.split('?'); @@ -210,6 +221,7 @@ $(window).resize(function() { jQuery(function() { restoreTabSelections(); initMermaid(); + scrollToActiveMenu(); jQuery('#sidebar .category-icon').on('click', function() { $( this ).toggleClass("fa-angle-down fa-angle-right") ;