'use client'; import { useEffect, useRef } from 'react'; /** * Lightweight reveal-on-scroll. Без зависимостей, нативный IntersectionObserver. * Дочерние элементы с классом `.reveal` плавно появятся. */ export default function Reveal({ children, className = '' }) { const ref = useRef(null); useEffect(() => { if (!ref.current) return; const io = new IntersectionObserver( entries => { entries.forEach(e => { if (e.isIntersecting) { e.target.classList.add('is-visible'); io.unobserve(e.target); } }); }, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' } ); ref.current.querySelectorAll('.reveal').forEach(el => io.observe(el)); return () => io.disconnect(); }, []); return (
{children}
); }