()
| 21 | }; |
| 22 | |
| 23 | const ScrollFloatDemo = () => { |
| 24 | const containerRef = useRef(null); |
| 25 | const { props, updateProp, resetProps, hasChanges } = useComponentProps(DEFAULT_PROPS); |
| 26 | const { stagger, duration } = props; |
| 27 | |
| 28 | const [key, forceRerender] = useForceRerender(); |
| 29 | |
| 30 | useEffect(() => { |
| 31 | const container = containerRef.current; |
| 32 | if (!container) return; |
| 33 | |
| 34 | const smoothScroll = e => { |
| 35 | e.preventDefault(); |
| 36 | const delta = e.deltaY || e.detail || e.wheelDelta; |
| 37 | const scrollAmount = delta * 2; |
| 38 | |
| 39 | gsap.to(container, { |
| 40 | scrollTop: container.scrollTop + scrollAmount, |
| 41 | duration: 2, |
| 42 | ease: 'power3.out', |
| 43 | overwrite: 'auto' |
| 44 | }); |
| 45 | }; |
| 46 | |
| 47 | container.addEventListener('wheel', smoothScroll, { passive: false }); |
| 48 | |
| 49 | return () => { |
| 50 | container.removeEventListener('wheel', smoothScroll); |
| 51 | }; |
| 52 | }, []); |
| 53 | |
| 54 | const propData = useMemo( |
| 55 | () => [ |
| 56 | { |
| 57 | name: 'children', |
| 58 | type: 'ReactNode', |
| 59 | default: '—', |
| 60 | description: 'The content to animate. If a string, it will be split into individual characters.' |
| 61 | }, |
| 62 | { |
| 63 | name: 'scrollContainerRef', |
| 64 | type: 'RefObject<HTMLElement>', |
| 65 | default: 'window', |
| 66 | description: 'Optional ref to the scroll container. Defaults to window if not provided.' |
| 67 | }, |
| 68 | { |
| 69 | name: 'containerClassName', |
| 70 | type: 'string', |
| 71 | default: '""', |
| 72 | description: 'Additional Tailwind classes for the container element.' |
| 73 | }, |
| 74 | { |
| 75 | name: 'textClassName', |
| 76 | type: 'string', |
| 77 | default: '""', |
| 78 | description: 'Additional Tailwind classes for the text element.' |
| 79 | }, |
| 80 | { |
nothing calls this directly
no test coverage detected