refactor: reorganize components and move files to appropriate directories

This commit is contained in:
Alvalen 2025-01-15 11:07:57 +07:00
parent b270dd1d21
commit 43a3d944ea
12 changed files with 7 additions and 7 deletions

View file

@ -0,0 +1,32 @@
// useIntersectionObserver.js
import { useEffect, useState, useRef } from "react";
export function useIntersectionObserver() {
const [isIntersecting, setIsIntersecting] = useState(false);
const ref = useRef(null);
useEffect(() => {
const observer = new IntersectionObserver(
([entry]) => {
setIsIntersecting(entry.isIntersecting);
},
{
root: null,
rootMargin: "0px",
threshold: 0.1,
}
);
if (ref.current) {
observer.observe(ref.current);
}
return () => {
if (ref.current) {
observer.unobserve(ref.current);
}
};
}, []);
return [ref, isIntersecting];
}