feat: legacy

This commit is contained in:
TrèsAbhi committed 2024-09-14 12:12:46 -05:00
1 parent 9640920863
commit 8d9ca3d716
271 files changed
+1 -1

No files matched your search

-26
View File
@@ -1,26 +0,0 @@
import { RefObject, useEffect, useRef, useState } from 'react';
/**
* Thanks GuCier!
*
* https://stackoverflow.com/a/65008608/12294756
*/
export function useOnScreen(ref: RefObject<HTMLElement>) {
const [isIntersecting, setIntersecting] = useState(false);
const observer = useRef<IntersectionObserver>();
useEffect(() => {
observer.current = new IntersectionObserver(([entry]) =>
setIntersecting(entry.isIntersecting),
);
}, [ref]);
useEffect(() => {
if (!ref.current) return;
observer.current?.observe(ref.current);
return () => observer.current?.disconnect();
}, [ref]);
return isIntersecting;
}