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

This commit is contained in:
2026-03-11 19:39:09 +00:00
parent fae97b71b9
commit bf9e7f8fc5

View File

@@ -1,17 +1,15 @@
'use client';
import { useEffect, useRef, useState } from 'react';
interface UseCardAnimationReturn {
isActive: boolean;
isMobile: boolean;
itemRefs: React.RefObject<HTMLElement>[];
}
import { UseCardAnimationReturn } from '@/components/cardStack/types';
export function useCardAnimation(): UseCardAnimationReturn {
const [isActive, setIsActive] = useState(false);
const [isMobile, setIsMobile] = useState(false);
const itemRefs = useRef<(HTMLElement | null)[]>([]);
const itemRefsArray = useRef<(HTMLElement | null)[]>([]);
const containerRef = useRef<HTMLElement>(null);
const perspectiveRef = useRef<HTMLElement>(null);
const bottomContentRef = useRef<HTMLElement>(null);
useEffect(() => {
const checkMobile = () => {
@@ -22,9 +20,16 @@ export function useCardAnimation(): UseCardAnimationReturn {
return () => window.removeEventListener('resize', checkMobile);
}, []);
const itemRefs = itemRefsArray.current.map((el) => ({
current: el,
})) as React.RefObject<HTMLElement>[];
return {
isActive,
isMobile,
itemRefs: itemRefs.current.map((el) => ({ current: el })) as React.RefObject<HTMLElement>[],
itemRefs,
containerRef,
perspectiveRef,
bottomContentRef,
};
}