Copy hooks/useHovering.ts to glitch-soc

This commit is contained in:
Claire
2023-05-09 21:30:10 +02:00
parent 8e806b6e88
commit 42bdc2add9
3 changed files with 21 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
import { useCallback, useState } from 'react';
export const useHovering = (animate?: boolean) => {
const [hovering, setHovering] = useState<boolean>(animate ?? false);
const handleMouseEnter = useCallback(() => {
if (animate) return;
setHovering(true);
}, [animate]);
const handleMouseLeave = useCallback(() => {
if (animate) return;
setHovering(false);
}, [animate]);
return { hovering, handleMouseEnter, handleMouseLeave };
};