Spaces:
Running
Running
Ashraf Al-Kassem
Claude Opus 4.6
feat: Mission 33 — Marketing Website Alignment + DB-Driven Content
6acfd72 Download Website/src/hooks/useIntersectionObserver.ts from ashrafkassem/LeadPilot: direct link, hf CLI and curl.
- Browser
- Download file 748 Bytes
-
https://huggingface.co/spaces/ashrafkassem/LeadPilot/resolve/main/Website/src/hooks/useIntersectionObserver.ts
- Command line
-
hf download hf://spaces/ashrafkassem/LeadPilot/Website/src/hooks/useIntersectionObserver.ts
-
curl -L -o useIntersectionObserver.ts https://huggingface.co/spaces/ashrafkassem/LeadPilot/resolve/main/Website/src/hooks/useIntersectionObserver.ts
748 Bytes
| "use client"; | |
| import { useEffect, useRef, type RefObject } from "react"; | |
| /** | |
| * Scroll-reveal hook: adds a CSS class when the element enters the viewport. | |
| * Fires once, then disconnects the observer. | |
| */ | |
| export function useReveal<T extends HTMLElement>( | |
| className = "reveal-visible", | |
| ): RefObject<T | null> { | |
| const ref = useRef<T>(null); | |
| useEffect(() => { | |
| const el = ref.current; | |
| if (!el) return; | |
| const observer = new IntersectionObserver( | |
| ([entry]) => { | |
| if (entry.isIntersecting) { | |
| el.classList.add(className); | |
| observer.unobserve(el); | |
| } | |
| }, | |
| { threshold: 0.1 }, | |
| ); | |
| observer.observe(el); | |
| return () => observer.disconnect(); | |
| }, [className]); | |
| return ref; | |
| } | |