Rename custom event

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. 🫠
This commit is contained in:
Marcus Blättermann 2022-12-13 05:41:41 +01:00
parent d6c9a07faa
commit 74e8249ca8
No known key found for this signature in database
GPG Key ID: A1E1F04008AC450D
2 changed files with 3 additions and 3 deletions

View File

@ -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 <section ref={ref} id={id} className={sectionClassNames} {...props} />

View File

@ -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)
}
})