From 74e8249ca8f68e04ed183498dc4cd0dd7f3520a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Bl=C3=A4ttermann?= Date: Tue, 13 Dec 2022 05:41:41 +0100 Subject: [PATCH] Rename custom event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I was googeling for ages to find out what kind of event `inview` is, only to figure out it was a custom event with a name that sounds pretty much like a native one. 🫠 --- website/src/components/section.js | 2 +- website/src/components/sidebar.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/website/src/components/section.js b/website/src/components/section.js index d21f88bb5..5bba20dce 100644 --- a/website/src/components/section.js +++ b/website/src/components/section.js @@ -13,7 +13,7 @@ export default function Section({ id, className, ...props }) { useEffect(() => { if (inView && relId) { - window.dispatchEvent(new CustomEvent('inview', { detail: relId })) + window.dispatchEvent(new CustomEvent('SPACY_SCROLL_HANDLER', { detail: relId })) } }, [inView, relId]) return
diff --git a/website/src/components/sidebar.js b/website/src/components/sidebar.js index f02daf9ea..db27dc23e 100644 --- a/website/src/components/sidebar.js +++ b/website/src/components/sidebar.js @@ -44,9 +44,9 @@ export default function Sidebar({ items = [], pageMenu = [], slug }) { useEffect(() => { const handleInView = ({ detail }) => setActiveSection(detail) - window.addEventListener('inview', handleInView, { passive: true }) + window.addEventListener('SPACY_SCROLL_HANDLER', handleInView, { passive: true }) return () => { - window.removeEventListener('inview', handleInView) + window.removeEventListener('SPACY_SCROLL_HANDLER', handleInView) } })