Update src/components/cardStack/hooks/useCardAnimation.ts

This commit is contained in:
2026-03-06 21:38:29 +00:00
parent 5d154806bc
commit fdda2fc714

View File

@@ -1,12 +1,31 @@
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
export function useCardAnimation() {
const [mounted, setMounted] = useState(false);
const isMobile = typeof window !== "undefined" && window.innerWidth < 768;
const itemRefs = useRef<(HTMLElement | null)[]>([]);
const bottomContentRef = useRef<HTMLDivElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
const perspectiveRef = useRef<HTMLDivElement>(null);
useEffect(() => {
setMounted(true);
}, []);
return { mounted, isMobile };
const setItemRef = (index: number, el: HTMLElement | null) => {
if (!itemRefs.current) {
itemRefs.current = [];
}
itemRefs.current[index] = el;
};
return {
mounted,
isMobile,
itemRefs,
setItemRef,
bottomContentRef,
containerRef,
perspectiveRef,
};
}