From 412f81fd3d69be59bfa6b84e1ccc634088a062fa Mon Sep 17 00:00:00 2001 From: Nate Contino Date: Fri, 7 Jun 2024 13:14:38 -0400 Subject: [PATCH 1/3] Fix issue where the docs site doesn't always scroll to the correct anchor location --- jekyll-assets/_includes/scripts.html | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/jekyll-assets/_includes/scripts.html b/jekyll-assets/_includes/scripts.html index 9dbc838ccc..1d6e89a43b 100644 --- a/jekyll-assets/_includes/scripts.html +++ b/jekyll-assets/_includes/scripts.html @@ -44,17 +44,14 @@ function scrollToElement(selector) { try { - // if found, scroll to that id hash - console.log("Scrolling to ", selector); var target = document.querySelector(selector); if (target) { var bbox = target.getBoundingClientRect(); var myid = target.getAttribute("id"); - window.scrollTo({ - top: bbox.top, - left: 0, - behavior: "smooth", - }); + setTimeout(function () { + target.scrollIntoView(); + },2); + } else { console.log("Target not found :("); } From 8abc701b00cc802d158733deda0f99c89fe3d059 Mon Sep 17 00:00:00 2001 From: Nate Contino Date: Fri, 7 Jun 2024 13:16:52 -0400 Subject: [PATCH 2/3] Remove unnecessary variables within if statement --- jekyll-assets/_includes/scripts.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/jekyll-assets/_includes/scripts.html b/jekyll-assets/_includes/scripts.html index 1d6e89a43b..fc4e97db19 100644 --- a/jekyll-assets/_includes/scripts.html +++ b/jekyll-assets/_includes/scripts.html @@ -46,8 +46,6 @@ try { var target = document.querySelector(selector); if (target) { - var bbox = target.getBoundingClientRect(); - var myid = target.getAttribute("id"); setTimeout(function () { target.scrollIntoView(); },2); From b18268bad35c491f71f87bc5a0220a9c3a50890e Mon Sep 17 00:00:00 2001 From: Nate Contino Date: Fri, 7 Jun 2024 14:13:37 -0400 Subject: [PATCH 3/3] Added fix for simulated 2G networks --- jekyll-assets/_includes/scripts.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jekyll-assets/_includes/scripts.html b/jekyll-assets/_includes/scripts.html index fc4e97db19..0d0bba4fcb 100644 --- a/jekyll-assets/_includes/scripts.html +++ b/jekyll-assets/_includes/scripts.html @@ -47,8 +47,12 @@ var target = document.querySelector(selector); if (target) { setTimeout(function () { - target.scrollIntoView(); - },2); + target.scrollIntoView({ behavior: "instant" }); + setTimeout(function () { + target.scrollIntoView({ behavior: "instant" }); + },100); + },1); + } else { console.log("Target not found :(");