(node: HTMLElement)
| 37 | } |
| 38 | |
| 39 | export function isInViewport(node: HTMLElement) { |
| 40 | if (!node) { |
| 41 | return false; |
| 42 | } |
| 43 | const { top, left, bottom, right } = node.getBoundingClientRect(); |
| 44 | return ( |
| 45 | top >= 0 && |
| 46 | left >= 0 && |
| 47 | bottom <= (window.innerHeight || document.documentElement.clientHeight) && |
| 48 | right <= (window.innerWidth || document.documentElement.clientWidth) |
| 49 | ); |
| 50 | } |
no outgoing calls
no test coverage detected