Created
January 20, 2021 16:29
-
-
Save tolumide-ng/1b6081d9e37acf41cca14f8996a16bdb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
interface entryDef { | |
isIntersecting: Boolean; | |
intersectionRatio: number; | |
} | |
interface IntersectionObserverDef { | |
ancestorElem?: Element, | |
} | |
export const useIntersectionObserver = (props: IntersectionObserverDef) => { | |
const [converge, setConverge] = React.useState(false); | |
React.useEffect(() => {}, [converge]); | |
function executeJob(entry: Array<entryDef>){ | |
entries.forEach((entry) => { | |
if(entry.isIntersecting){ | |
setConverge(true); | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment