(element: HTMLElement)
| 198 | // ------------------------------ |
| 199 | |
| 200 | export function getScrollParent(element: HTMLElement) { |
| 201 | let style = getComputedStyle(element); |
| 202 | const excludeStaticParent = style.position === 'absolute'; |
| 203 | const overflowRx = /(auto|scroll)/; |
| 204 | |
| 205 | if (style.position === 'fixed') return document.documentElement; |
| 206 | |
| 207 | for ( |
| 208 | let parent: HTMLElement | null = element; |
| 209 | (parent = parent.parentElement); |
| 210 | |
| 211 | ) { |
| 212 | style = getComputedStyle(parent); |
| 213 | if (excludeStaticParent && style.position === 'static') { |
| 214 | continue; |
| 215 | } |
| 216 | if (overflowRx.test(style.overflow + style.overflowY + style.overflowX)) { |
| 217 | return parent; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | return document.documentElement; |
| 222 | } |
| 223 | |
| 224 | // Animated Scroll To |
| 225 | // ------------------------------ |
no outgoing calls
no test coverage detected
searching dependent graphs…