* Determine if an element is fully outside of the current viewport. * @param el - Element to test
(el: Element)
| 132 | * @param el - Element to test |
| 133 | */ |
| 134 | function isOffscreen(el: Element): boolean { |
| 135 | const rect = (el as HTMLElement).getBoundingClientRect() |
| 136 | const vw = root?.clientWidth || 0 |
| 137 | const vh = root?.clientHeight || 0 |
| 138 | return rect.bottom < 0 || rect.top > vh || rect.right < 0 || rect.left > vw |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Observe this elements position. |