mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-25 17:51:36 +01:00
4520e6473a
Co-authored-by: berlysia <berlysia@gmail.com> Co-authored-by: fusagiko / takayamaki <takayamaki@users.noreply.github.com>
17 lines
461 B
TypeScript
17 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 };
|
|
};
|