(element: Element, root: Element)
| 71 | |
| 72 | // The top of the element relative to the top of the root (e.g. the content of a scroll container) |
| 73 | function getLayoutTop(element: Element, root: Element): number { |
| 74 | let top = 0; |
| 75 | let node: Element = element; |
| 76 | while (node !== root && node.parentElement) { |
| 77 | if (isAbsolutelyPositioned(node)) { |
| 78 | top += parsePixels(getStyle(node)?.top ?? "") ?? 0; |
| 79 | } else { |
| 80 | for ( |
| 81 | let sibling = node.previousElementSibling; |
| 82 | sibling; |
| 83 | sibling = sibling.previousElementSibling |
| 84 | ) { |
| 85 | if (!isAbsolutelyPositioned(sibling)) { |
| 86 | top += getLayoutHeight(sibling); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | node = node.parentElement; |
| 91 | } |
| 92 | return top; |
| 93 | } |
| 94 | |
| 95 | function getClosestContainer(element: Element): Element | null { |
| 96 | for ( |
no test coverage detected