Skip to content

Instantly share code, notes, and snippets.

@tolumide-ng
Created January 20, 2021 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolumide-ng/1b6081d9e37acf41cca14f8996a16bdb to your computer and use it in GitHub Desktop.
Save tolumide-ng/1b6081d9e37acf41cca14f8996a16bdb to your computer and use it in GitHub Desktop.
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