From dbc209442442b8a4df7233a6488e3b822d1459c4 Mon Sep 17 00:00:00 2001 From: Nick Lyons <104778659+nick-mon1@users.noreply.github.com> Date: Wed, 15 May 2024 15:17:45 -0400 Subject: [PATCH] Clarified comments for the heading calculations --- themes/digital.gov/src/js/guide-sidenav.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/digital.gov/src/js/guide-sidenav.js b/themes/digital.gov/src/js/guide-sidenav.js index 6f36d82256..c7f5ce75bb 100644 --- a/themes/digital.gov/src/js/guide-sidenav.js +++ b/themes/digital.gov/src/js/guide-sidenav.js @@ -154,12 +154,12 @@ function findTopHeading( // Recursive case /* eslint-disable no-param-reassign */ - // Calculate the distance of the current heading fro the top of the page - // getBoundingClientRect().top gives the distance from the viewport, so we add the scrollY to get the distance from the top of the page + // Calculate the distance of the current heading from the top of the page + // getBoundingClientRect().top gives the distance from the element to the top of the viewport, then we add the scrollY to get the distance from the top of the viewport to the top of the page const currentHeadingTop = headings[i].getBoundingClientRect().top + window.scrollY; - // Calculate the distance of the next heading from the top of the document, if there is a next heading + // Calculate the distance of the next heading from the top of the document, if there is a next heading // If there is no next heading, set nextHeadingTop to Infinity const nextHeadingTop = i < headings.length - 1