about summary refs log tree commit diff
path: root/app/javascript/hooks
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-04-04 12:01:52 +0200
committerGitHub <noreply@github.com>2023-04-04 12:01:52 +0200
commitaf01ab7efebab356e73b498afe4258ae7515cc6a (patch)
tree798f5cde568987b7641543eb3972f355bae9170b /app/javascript/hooks
parent8192b0da7cd1fac38a68eab6746fc7ec74328a77 (diff)
parentd29cf8a044f6c0d004649223e018d240983e8437 (diff)
Merge pull request #2159 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/hooks')
-rw-r--r--app/javascript/hooks/useHovering.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/javascript/hooks/useHovering.ts b/app/javascript/hooks/useHovering.ts
new file mode 100644
index 000000000..2062e70d2
--- /dev/null
+++ b/app/javascript/hooks/useHovering.ts
@@ -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 };
+};