()
| 6 | const [state, setState] = React.useState({display: 'none', opacity: 0}); |
| 7 | React.useEffect(() => { |
| 8 | const scrollHandler = () => { |
| 9 | const currentScrollPos = Math.max(window.pageYOffset - 1000, 0); |
| 10 | const opacity = Math.min(currentScrollPos / 1000, 1); |
| 11 | const nextState = {display: currentScrollPos > 0 ? 'inherit' : 'none', opacity}; |
| 12 | if (state.display !== nextState.display || state.opacity !== nextState.opacity) { |
| 13 | setState(nextState); |
| 14 | } |
| 15 | }; |
| 16 | window.addEventListener('scroll', scrollHandler); |
| 17 | return () => window.removeEventListener('scroll', scrollHandler); |
| 18 | }, []); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…