From f5e0f2762a1bde324cc97ac1c68313b8eb59ff20 Mon Sep 17 00:00:00 2001 From: Josh Heyer Date: Wed, 11 Oct 2023 18:56:16 +0000 Subject: [PATCH] Just disable smooth scrolling across the board Then rely on default behavior. --- gatsby-browser.js | 17 ----------------- src/styles/_helpers.scss | 8 ++++++-- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/gatsby-browser.js b/gatsby-browser.js index 06f4436132a..feb9f696645 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -3,23 +3,6 @@ require("prismjs/plugins/command-line/prism-command-line.css"); exports.onRouteUpdate = ({ location }) => scrollToAnchor(location); -exports.shouldUpdateScroll = ({ - prevRouterProps, - routerProps, - pathname, - getSavedScrollPosition, -}) => { - let hashElem = - routerProps.location.hash && - document.getElementById(routerProps.location.hash.substring(1)); - // avoid obscure issue where scrolling to hash in gatsby-react-router-scroll slams to end of page if animated - if (hashElem) { - hashElem.scrollIntoView({ behavior: "instant" }); - return false; - } - return true; // default -}; - /** * * @desc - a function to jump to the correct scroll position diff --git a/src/styles/_helpers.scss b/src/styles/_helpers.scss index 1ae1243f461..160ad81d649 100644 --- a/src/styles/_helpers.scss +++ b/src/styles/_helpers.scss @@ -123,8 +123,12 @@ svg { .arrow-list { list-style-type: "→"; } -html { - scroll-behavior: smooth; + + +// force-disable this - it causes annoying jumps when navigating, and a bug w/ anchor links in Firefox +$enable-smooth-scroll: false; +:root { + scroll-behavior: auto !important; } /* fill colors */