| 69 | }; |
| 70 | |
| 71 | const useScrolledToBottom = ref => { |
| 72 | const [isScrolledToBottom, setIsScrolledToBottom] = useState(false); |
| 73 | |
| 74 | useEffect(() => { |
| 75 | const el = ref.current; |
| 76 | if (!el) return; |
| 77 | |
| 78 | const handleScroll = () => { |
| 79 | const { scrollTop, scrollHeight, clientHeight } = el; |
| 80 | setIsScrolledToBottom(scrollTop + clientHeight >= scrollHeight - 10); |
| 81 | }; |
| 82 | |
| 83 | el.addEventListener('scroll', handleScroll); |
| 84 | handleScroll(); |
| 85 | return () => el.removeEventListener('scroll', handleScroll); |
| 86 | }, [ref]); |
| 87 | |
| 88 | return isScrolledToBottom; |
| 89 | }; |
| 90 | |
| 91 | // ─── Sub-components ────────────────────────────────────────────────────────── |
| 92 | const ActiveLine = ({ position, isVisible }) => ( |
no test coverage detected