(smaller, larger)
| 118 | * @visibleForTesting |
| 119 | */ |
| 120 | export function intersectionRatio(smaller, larger) { |
| 121 | const smallerBoxArea = smaller.width * smaller.height; |
| 122 | const largerBoxArea = larger.width * larger.height; |
| 123 | |
| 124 | // Check for a divide by zero |
| 125 | return largerBoxArea === 0 ? 0 : smallerBoxArea / largerBoxArea; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Helper function to calculate the IntersectionObserver change entry. |
no outgoing calls
no test coverage detected