( containerElement: HTMLElement, direction: Direction )
| 65 | * (e.g. a grid that scrolls its columns while rows scroll with the page). |
| 66 | */ |
| 67 | export function isSelfScrolling( |
| 68 | containerElement: HTMLElement, |
| 69 | direction: Direction |
| 70 | ): boolean { |
| 71 | const { overflowX, overflowY } = |
| 72 | getOwnerWindow(containerElement).getComputedStyle(containerElement); |
| 73 | const overflow = direction === "vertical" ? overflowY : overflowX; |
| 74 | if (overflow === "visible" || overflow === "clip") { |
| 75 | // Rows that overflow their estimated size can't be scrolled to |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | // Allow for rounding (scroll and client sizes are rounded separately, e.g. for fractional item sizes) |
| 80 | return direction === "vertical" |
| 81 | ? containerElement.scrollHeight - containerElement.clientHeight > 1 |
| 82 | : containerElement.scrollWidth - containerElement.clientWidth > 1; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Measures the region of the container that is visible within the scroll element's viewport. |
no test coverage detected