| 195 | } |
| 196 | |
| 197 | private findScrollContainer(element: HTMLElement): HTMLElement { |
| 198 | let current: HTMLElement | null = element; |
| 199 | |
| 200 | // Walk up the DOM tree to find an element with overflow scroll/auto |
| 201 | while (current) { |
| 202 | const style = window.getComputedStyle(current); |
| 203 | const overflowY = style.overflowY; |
| 204 | |
| 205 | if (overflowY === "scroll" || overflowY === "auto") { |
| 206 | return current; |
| 207 | } |
| 208 | |
| 209 | current = current.parentElement; |
| 210 | } |
| 211 | |
| 212 | // Fallback to container itself |
| 213 | return element; |
| 214 | } |
| 215 | |
| 216 | private getContainerBottomPadding(): number { |
| 217 | const view = this.container.ownerDocument.defaultView; |