in packages/appear/src/web/intersection-observer.ts [318:360]
_computeTargetAndRootIntersection(target, rootRect) {
// If the element isn't displayed, an intersection can't happen.
if (window.getComputedStyle(target).display == 'none') return;
let targetRect = getBoundingClientRect(target);
let intersectionRect = targetRect;
let parent = getParentNode(target);
let atRoot = false;
while (!atRoot) {
let parentRect = null;
let parentComputedStyle = parent.nodeType == 1
? window.getComputedStyle(parent) : {};
// If the parent isn't displayed, an intersection can't happen.
if (parentComputedStyle.display === 'none') return;
if (parent === this.root || parent === document) {
atRoot = true;
parentRect = rootRect;
} else {
// If the element has a non-visible overflow, and it's not the <body>
// or <html> element, update the intersection rect.
// Note: <body> and <html> cannot be clipped to a rect that's not also
// the document rect, so no need to compute a new intersection.
if (parent !== document.body &&
parent !== document.documentElement &&
parentComputedStyle.overflow !== 'visible') {
parentRect = getBoundingClientRect(parent);
}
}
// If either of the above conditionals set a new parentRect,
// calculate new intersection data.
if (parentRect) {
intersectionRect = computeRectIntersection(parentRect, intersectionRect);
if (!intersectionRect) break;
}
parent = getParentNode(parent);
}
return intersectionRect;
}