mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(site): new home page, docs, and design system (#566)
Co-authored-by: Darius Cepulis <dcepulis@mux.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Darius Cepulis
Claude Opus 4.6
parent
f2f9e6ddc3
commit
351a3e8bda
@@ -0,0 +1,27 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
export function useIntersection(options?: IntersectionObserverInit): [React.RefCallback<Element>, boolean] {
|
||||
const [isIntersecting, setIsIntersecting] = useState(false);
|
||||
const observerRef = useRef<IntersectionObserver | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
return () => observerRef.current?.disconnect();
|
||||
}, []);
|
||||
|
||||
const ref = (node: Element | null) => {
|
||||
observerRef.current?.disconnect();
|
||||
|
||||
if (!node || isIntersecting) return;
|
||||
|
||||
observerRef.current = new IntersectionObserver(([entry]) => {
|
||||
if (entry?.isIntersecting) {
|
||||
setIsIntersecting(true);
|
||||
observerRef.current?.disconnect();
|
||||
}
|
||||
}, options);
|
||||
|
||||
observerRef.current.observe(node);
|
||||
};
|
||||
|
||||
return [ref, isIntersecting];
|
||||
}
|
||||
Reference in New Issue
Block a user