From 16c8c5ed1c01dfbcc57da5986debc29bf895490f Mon Sep 17 00:00:00 2001 From: Cristen Jones Date: Thu, 26 Dec 2024 16:02:00 -0500 Subject: [PATCH] cleanup: remove unused JS code --- assets/js/app.js | 2 -- assets/js/scroll-to.js | 38 -------------------------------------- 2 files changed, 40 deletions(-) delete mode 100644 assets/js/scroll-to.js diff --git a/assets/js/app.js b/assets/js/app.js index cd5be24330..4d771675cd 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -17,7 +17,6 @@ import geoLocation from "./geolocation"; import addressSearch from "./address-search"; import googleTranslate from "./google-translate"; import translateAnalytics from "./translate-analytics.js"; -import scrollTo from "./scroll-to"; import stickyTooltip from "./sticky-tooltip"; import timetableScroll from "./timetable-scroll"; import timetableStyle from "./timetable-style"; @@ -132,7 +131,6 @@ geoLocation(); addressSearch(); googleTranslate(); translateAnalytics(); -scrollTo(); tabbedNav(); timetableScroll(); timetableStyle(); diff --git a/assets/js/scroll-to.js b/assets/js/scroll-to.js deleted file mode 100644 index 85ce11066b..0000000000 --- a/assets/js/scroll-to.js +++ /dev/null @@ -1,38 +0,0 @@ -export default () => { - window.addEventListener("load", scrollTo, { passive: true }); -}; - -const scrollTo = () => { - window.requestAnimationFrame(() => { - const initialElToScrollTo = document.querySelector("[data-scroll-to]"); - if (initialElToScrollTo) { - doScrollTo(initialElToScrollTo); - } - }); -}; - -const doScrollTo = el => { - const childLeft = el.offsetLeft; - const parentLeft = el.parentNode.offsetLeft; - const firstSiblingWidth = firstSibling(el).clientWidth; - - // childLeft - parentLeft scrolls the first row to the start of the - // visible area. - const scrollLeft = childLeft - parentLeft - firstSiblingWidth; - let table = el.parentNode; - while (table.nodeName !== "TABLE") { - table = table.parentNode; - } - table.parentNode.scrollLeft = scrollLeft; -}; - -const firstSibling = element => { - const sibling = element.parentNode.firstChild; - if (sibling.nodeType === 1) { - return sibling; - } else if (sibling) { - return sibling.nextElementSibling; - } else { - return null; - } -};