refactor: reorganize components and move files to appropriate directories
This commit is contained in:
parent
b270dd1d21
commit
43a3d944ea
12 changed files with 7 additions and 7 deletions
32
app/about/components/quote/useIntersectionObserver.js
Normal file
32
app/about/components/quote/useIntersectionObserver.js
Normal 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];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue