(element: ResolvedScrollElement)
| 71 | * and API differences between `window` and other DOM elements. |
| 72 | */ |
| 73 | export function getScrollOffset(element: ResolvedScrollElement): Offset { |
| 74 | if (isWindow(element) && document.documentElement) { |
| 75 | return { |
| 76 | top: |
| 77 | "scrollY" in window |
| 78 | ? window.scrollY |
| 79 | : document.documentElement.scrollTop, |
| 80 | left: |
| 81 | "scrollX" in window |
| 82 | ? window.scrollX |
| 83 | : document.documentElement.scrollLeft |
| 84 | }; |
| 85 | } else { |
| 86 | return { |
| 87 | top: (element as Element).scrollTop, |
| 88 | left: (element as Element).scrollLeft |
| 89 | }; |
| 90 | } |
| 91 | } |
no test coverage detected