MCPcopy Index your code
hub / github.com/ampproject/amphtml / intersectionRatio

Function intersectionRatio

src/utils/intersection-observer-3p-host.js:120–126  ·  view source on GitHub ↗
(smaller, larger)

Source from the content-addressed store, hash-verified

118 * @visibleForTesting
119 */
120export 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.

Calls

no outgoing calls

Tested by

no test coverage detected