diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-27 00:55:15 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:56:48 +0200 |
| commit | 4d127a038bf768eded68aae3cfa5c1b12241bdac (patch) | |
| tree | 16bbb801caf6770546cff4fdb37b6408ec9ead98 /legacy/use-reveal-item.ts | |
| parent | 82817cb50cb0487350573d6129130aec705f924b (diff) | |
| download | opencut-4d127a038bf768eded68aae3cfa5c1b12241bdac.tar.gz | |
chore: normalize line endings
Diffstat (limited to 'legacy/use-reveal-item.ts')
| -rw-r--r-- | legacy/use-reveal-item.ts | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/legacy/use-reveal-item.ts b/legacy/use-reveal-item.ts index f77ef17f..dd13d844 100644 --- a/legacy/use-reveal-item.ts +++ b/legacy/use-reveal-item.ts @@ -1,28 +1,28 @@ -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 }; -} +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 };
+}
|
