/** * Detail view, displaying text plus media */ import React, { useRef, useEffect, useState, useCallback } from "react"; import Gallery from "./Gallery.js"; import Clocks from "./Clocks.js"; import Vimeo from "@u-wave/react-vimeo"; import { pad } from "../utils/index.js"; export default function Detail({ node, visible, onClose }) { const ref = useRef(); const contentRef = useRef(); const [videoReady, setVideoReady] = useState(false); useEffect(() => { if (!node) { setVideoReady(false); } setTimeout(() => { ref.current.scrollTo(0, -ref.current.scrollHeight); if (contentRef.current) { contentRef.current.scrollTo(0, -ref.current.scrollHeight); } }, 10); }, [node]); const handleVideoReady = useCallback(() => { if (node.data.object) { setTimeout(() => { setVideoReady(true); }, 500); } else { setVideoReady(true); } }, [node]); const handleLoad = useCallback(() => { ref.current.scrollTo(0, -ref.current.scrollHeight); }); if (!node) { return
; } const { id, data } = node; const index = id + 1; return (