(node: Element | null, checkForOverflow?: boolean)
| 11 | */ |
| 12 | |
| 13 | export function isScrollable(node: Element | null, checkForOverflow?: boolean): boolean { |
| 14 | if (!node) { |
| 15 | return false; |
| 16 | } |
| 17 | let style = window.getComputedStyle(node); |
| 18 | let root = document.scrollingElement || document.documentElement; |
| 19 | let isScrollable = /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY); |
| 20 | |
| 21 | // Root element has `visible` overflow by default, but is scrollable nonetheless. |
| 22 | if (node === root && style.overflow !== 'hidden') { |
| 23 | isScrollable = true; |
| 24 | } |
| 25 | |
| 26 | if (isScrollable && checkForOverflow) { |
| 27 | isScrollable = node.scrollHeight !== node.clientHeight || node.scrollWidth !== node.clientWidth; |
| 28 | } |
| 29 | |
| 30 | return isScrollable; |
| 31 | } |
no outgoing calls
no test coverage detected