Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
901 B
TypeScript
30 lines
901 B
TypeScript
"use client";
|
|
|
|
import { useEffect, useRef } from "react";
|
|
|
|
/** Scroll to a DOM id and briefly highlight after data loads. */
|
|
export function useLiveFocusScroll(
|
|
focusId: string | null | undefined,
|
|
elementIdPrefix: string,
|
|
ready: boolean,
|
|
) {
|
|
const doneRef = useRef<string | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (!focusId || !ready) return;
|
|
const token = `${elementIdPrefix}${focusId}`;
|
|
if (doneRef.current === token) return;
|
|
|
|
const el = document.getElementById(`${elementIdPrefix}${focusId}`);
|
|
if (!el) return;
|
|
|
|
doneRef.current = token;
|
|
const t = window.setTimeout(() => {
|
|
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
el.classList.add("yt-live-focus-highlight");
|
|
window.setTimeout(() => el.classList.remove("yt-live-focus-highlight"), 4500);
|
|
}, 280);
|
|
return () => clearTimeout(t);
|
|
}, [focusId, ready, elementIdPrefix]);
|
|
}
|