()
| 305 | if (!preElement) return |
| 306 | |
| 307 | const handleScroll = () => { |
| 308 | const isAtBottom = |
| 309 | Math.abs(preElement.scrollHeight - preElement.scrollTop - preElement.clientHeight) < |
| 310 | SCROLL_SNAP_TOLERANCE |
| 311 | wasScrolledUpRef.current = !isAtBottom |
| 312 | } |
| 313 | |
| 314 | preElement.addEventListener("scroll", handleScroll, { passive: true }) |
| 315 | // Initial check in case it starts scrolled up |