From 74a4b2f59694fd4daa2fa63ff013fda2b0b8c9b9 Mon Sep 17 00:00:00 2001 From: Matt Albright Date: Wed, 5 Jun 2024 14:07:29 -0700 Subject: [PATCH] Make section scrolling work with modified CSS 190px is hardcoded in the Javascript, whereas a user of this theme can easily override the size of the header and banner, and hence the location of the top of the main section. This change makes the scrollTop location when clicking a nav link always be correct, instead of assuming the main section is always 190px from the top. --- assets/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/main.js b/assets/js/main.js index 811bd2ea13..bb7e2c1d0b 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -20,7 +20,7 @@ $(function() { }); $("nav ul li").on("click", "a", function(event) { - var position = $($(this).attr("href")).offset().top - 190; + var position = $($(this).attr("href")).offset().top - parseInt($('section').css('margin-top')); $("html, body").animate({scrollTop: position}, 400); $("nav ul li a").parent().removeClass("active"); $(this).parent().addClass("active");