Files
dalcode-website/components/ScrollReveal.tsx
T
Leon-in 97db9ee8c7 feat(site): redesign with product pages, ecosystem sections and pixel reveal
Add cli/code/office/platform/pricing pages, new home sections
(Ecosystem, FeatureGrid, Faq, WorkflowSteps, BottomCta, ProductEcosystem),
ScrollReveal and PixelTextReveal animation components, brand assets,
and expanded site-content.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 14:00:18 +08:00

43 lines
839 B
TypeScript

"use client"
import { useEffect, useRef } from "react"
interface ScrollRevealProps {
children: React.ReactNode
className?: string
delay?: number
}
export default function ScrollReveal({
children,
className = "",
delay = 0,
}: ScrollRevealProps) {
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
const el = ref.current
if (!el) return
const observer = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting) {
setTimeout(() => {
el.classList.add("reveal-visible")
}, delay)
observer.unobserve(el)
}
},
{ threshold: 0.1 },
)
observer.observe(el)
return () => observer.disconnect()
}, [delay])
return (
<div ref={ref} className={`reveal-up ${className}`}>
{children}
</div>
)
}