From b7e359d0ba68286ee2fa2a333adc204b08664d90 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:14:28 +0330 Subject: [PATCH] Import source: cshare-app/src/hooks/useScrollReveal Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- cshare-app/src/hooks/useScrollReveal.js | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cshare-app/src/hooks/useScrollReveal.js diff --git a/cshare-app/src/hooks/useScrollReveal.js b/cshare-app/src/hooks/useScrollReveal.js new file mode 100644 index 0000000..9d95bb1 --- /dev/null +++ b/cshare-app/src/hooks/useScrollReveal.js @@ -0,0 +1,30 @@ +import { useEffect, useRef } from 'react'; + +export function useScrollReveal(threshold = 0.15) { + const ref = useRef(null); + + useEffect(() => { + const el = ref.current; + if (!el) return; + + const children = el.querySelectorAll('.scroll-reveal'); + if (children.length === 0) return; + + const observer = new IntersectionObserver( + (entries) => { + entries.forEach((entry) => { + if (entry.isIntersecting) { + entry.target.classList.add('revealed'); + observer.unobserve(entry.target); + } + }); + }, + { threshold, rootMargin: '0px 0px -40px 0px' } + ); + + children.forEach((child) => observer.observe(child)); + return () => observer.disconnect(); + }, [threshold]); + + return ref; +}