feat: add animate quote at about page

This commit is contained in:
Alvalen 2024-07-01 15:41:21 +07:00
parent e605b2e975
commit 93eb451880
5 changed files with 167 additions and 1 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];
}