MCPcopy
hub / github.com/DavidHDev/react-bits / ScrollRevealDemo

Function ScrollRevealDemo

src/demo/TextAnimations/ScrollRevealDemo.jsx:27–227  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25};
26
27const ScrollRevealDemo = () => {
28 const containerRef = useRef(null);
29
30 const { props, updateProp, resetProps, hasChanges } = useComponentProps(DEFAULT_PROPS);
31 const { enableBlur, baseOpacity, baseRotation, blurStrength } = props;
32
33 const [key, forceRerender] = useForceRerender();
34
35 useEffect(() => {
36 const container = containerRef.current;
37 if (!container) return;
38
39 const smoothScroll = e => {
40 e.preventDefault();
41 const delta = e.deltaY || e.detail || e.wheelDelta;
42 const scrollAmount = delta * 2;
43
44 gsap.to(container, {
45 scrollTop: container.scrollTop + scrollAmount,
46 duration: 2,
47 ease: 'power3.out',
48 overwrite: 'auto'
49 });
50 };
51
52 container.addEventListener('wheel', smoothScroll, { passive: false });
53
54 return () => {
55 container.removeEventListener('wheel', smoothScroll);
56 };
57 }, []);
58
59 const propData = useMemo(
60 () => [
61 {
62 name: 'children',
63 type: 'ReactNode',
64 default: '—',
65 description: 'The text or elements to be animated. If a string is provided, it will be split into words.'
66 },
67 {
68 name: 'scrollContainerRef',
69 type: 'React.RefObject',
70 default: 'window',
71 description:
72 'Optional ref for the scroll container. If provided, GSAP will use this container for scroll triggers; otherwise, it defaults to the window.'
73 },
74 {
75 name: 'enableBlur',
76 type: 'boolean',
77 default: 'true',
78 description: 'Enables the blur animation effect on the words.'
79 },
80 {
81 name: 'baseOpacity',
82 type: 'number',
83 default: '0.1',
84 description: 'The initial opacity value for the words before the animation.'

Callers

nothing calls this directly

Calls 2

useComponentPropsFunction · 0.85
useForceRerenderFunction · 0.85

Tested by

no test coverage detected