Spaces:
Sleeping
Sleeping
Download hooks/useSectionAudio.ts from Keep-Triangle/PratikWebsite: direct link, hf CLI and curl.
- Browser
- Download file 542 Bytes
-
https://huggingface.co/spaces/Keep-Triangle/PratikWebsite/resolve/main/hooks/useSectionAudio.ts
- Command line
-
hf download hf://spaces/Keep-Triangle/PratikWebsite/hooks/useSectionAudio.ts
-
curl -L -o useSectionAudio.ts https://huggingface.co/spaces/Keep-Triangle/PratikWebsite/resolve/main/hooks/useSectionAudio.ts
542 Bytes
| import { useEffect } from 'react'; | |
| import { useInView } from 'framer-motion'; | |
| import { useAudio } from '../context/AudioContext'; | |
| export const useSectionAudio = (ref: React.RefObject<HTMLElement>, audioUrl: string | null) => { | |
| const isInView = useInView(ref, { amount: 0.5 }); // Trigger when 50% visible | |
| const { setSectionAudio, isMuted } = useAudio(); | |
| useEffect(() => { | |
| if (isInView && !isMuted) { | |
| setSectionAudio(audioUrl); | |
| } | |
| }, [isInView, audioUrl, setSectionAudio, isMuted]); | |
| }; |