summaryrefslogtreecommitdiff
path: root/legacy/use-reveal-item.ts
diff options
context:
space:
mode:
Diffstat (limited to 'legacy/use-reveal-item.ts')
-rw-r--r--legacy/use-reveal-item.ts28
1 files changed, 0 insertions, 28 deletions
diff --git a/legacy/use-reveal-item.ts b/legacy/use-reveal-item.ts
deleted file mode 100644
index dd13d844..00000000
--- a/legacy/use-reveal-item.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { useEffect, useState } from "react";
-
-export function useRevealItem(
- highlightId: string | null,
- onClearHighlight: () => void,
- getElement: (id: string) => HTMLElement | null,
- highlightDuration = 1000,
-) {
- const [highlightedId, setHighlightedId] = useState<string | null>(null);
-
- useEffect(() => {
- if (!highlightId) return;
-
- setHighlightedId(highlightId);
-
- const target = getElement(highlightId);
- target?.scrollIntoView({ block: "center" });
-
- const timeout = setTimeout(() => {
- setHighlightedId(null);
- onClearHighlight();
- }, highlightDuration);
-
- return () => clearTimeout(timeout);
- }, [highlightId, onClearHighlight, highlightDuration, getElement]);
-
- return { highlightedId };
-}