mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-12-05 03:19:04 +01:00
18 lines
461 B
TypeScript
18 lines
461 B
TypeScript
|
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 };
|
||
|
};
|