Adds hero component
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export default function useScrolledPast(getThreshold: () => number) {
|
||||
const [scrolled, setScrolled] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const onScroll = () => setScrolled(window.scrollY > getThreshold());
|
||||
onScroll();
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
return () => window.removeEventListener('scroll', onScroll);
|
||||
}, [getThreshold]);
|
||||
|
||||
return scrolled;
|
||||
}
|
||||
Reference in New Issue
Block a user