Move app/javascript/hooks
to app/javascript/mastodon/hooks
(#34077)
This commit is contained in:
parent
00dbefdbbf
commit
b57687083f
20 changed files with 15 additions and 17 deletions
17
app/javascript/mastodon/hooks/useHovering.ts
Normal file
17
app/javascript/mastodon/hooks/useHovering.ts
Normal 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 };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue