From 610f22a1eb75effc93d3a52b20c97818c5acac9b Mon Sep 17 00:00:00 2001 From: Paul Hibbitts Date: Fri, 11 Oct 2024 08:36:52 -0700 Subject: [PATCH] Revert "Add smooth scrolling to scroll offset fix." This reverts commit 05ab036aa302c4e35e4e3564244a4afb722a0e4a. --- docs/index.html | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/docs/index.html b/docs/index.html index 0eada657..62eddfac 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1215,38 +1215,24 @@ return; // Exit if basePath is present } - let TARGET_QUERY = 'id'; - let SCROLL_DELAY = 500; // in milliseconds - let location = window.location; + let TARGET_QUERY = 'id' + let SCROLL_DELAY = 1000 // in milisecond + let location = window.location - // Build the current URL without the hash let currentUrlWithoutHash = new URL( - location.origin + location.pathname + - location.search + location.hash.substring(1) - ); - - // Get the search parameters from the URL - let urlQueryParam = currentUrlWithoutHash.searchParams; - let isUrlHasIdQuery = urlQueryParam.has(TARGET_QUERY); - - // Check if the URL contains the 'id' query parameter - if (isUrlHasIdQuery) { - let urlId = urlQueryParam.get(TARGET_QUERY); - - // Delay the scrolling to ensure everything is loaded - setTimeout(function () { - try { - let targetElement = document.querySelector('#' + urlId); - if (targetElement) { - // Scroll to the element with smooth behavior - targetElement.scrollIntoView({ - behavior: 'smooth', // Enables smooth scrolling - block: 'start', // Aligns the top of the element to the top of the viewport - }); - } - } catch (e) { - console.log('custom scroll failed', e); - } + location.origin+location.pathname+ + location.search+location.hash.substring(1) + ) + let urlQueryParam = currentUrlWithoutHash.searchParams + let isUrlHasIdQuery = urlQueryParam.has(TARGET_QUERY) + if(isUrlHasIdQuery){ + let urlId = urlQueryParam.get(TARGET_QUERY) + // run delayed, to make sure everything loaded + setTimeout(function() { + try{ + document.querySelector('#'+urlId) + .scrollIntoView() + } catch(e){ console.log('custom scroll failed',e) } }, SCROLL_DELAY); }