()
| 3 | import useListener from "./useListener" |
| 4 | |
| 5 | export function useScrollShadow() { |
| 6 | const [ref, setRef] = useCallbackRef() |
| 7 | |
| 8 | useEffect(() => { |
| 9 | ref?.classList.add("scroll-shadow") |
| 10 | return () => { |
| 11 | ref?.classList.remove("scroll-shadow") |
| 12 | } |
| 13 | }, [ref]) |
| 14 | |
| 15 | useListener(ref, "scroll", (e: UIEvent<HTMLElement>) => { |
| 16 | if (e.currentTarget.scrollTop === 0) { |
| 17 | e.currentTarget.classList.remove("scroll-shadow-show") |
| 18 | } else { |
| 19 | e.currentTarget.classList.add("scroll-shadow-show") |
| 20 | } |
| 21 | }) |
| 22 | |
| 23 | return setRef |
| 24 | } |
nothing calls this directly
no test coverage detected