src/IntersectionObservation.js
function computeIntersection(rootRect, targetRect) {
    const left      = Math.max(targetRect.left, rootRect.left);
    const right     = Math.min(targetRect.right, rootRect.right);
    const top       = Math.max(targetRect.top, rootRect.top);
    const bottom    = Math.min(targetRect.bottom, rootRect.bottom);

    const width = right - left;
    const height = bottom - top;

    return createRectangle(left, top, width, height);
}
function computeIntersection(rootRect, targetRect) {
    const left      = Math.max(targetRect.left, rootRect.left);
    const right     = Math.min(targetRect.right, rootRect.right);
    const top       = Math.max(targetRect.top, rootRect.top);
    const bottom    = Math.min(targetRect.bottom, rootRect.bottom);

    const width = right - left;
    const height = bottom - top;

    return createRectangle(left, top, width, height);
}
function computeIntersection ( rootRect , targetRect ) { const left = Math . max ( targetRect . left , rootRect . left ) ; const right = Math . min ( targetRect . right , rootRect . right ) ; const top = Math . max ( targetRect . top , rootRect . top ) ; const bottom = Math . min ( targetRect . bottom , rootRect . bottom ) ; const width = right - left ; const height = bottom - top ; return createRectangle ( left , top , width , height ) ; }
Computes intersection rectangle between two rectangles.

@param {ClientRect} rootRect - Rectangle of container element.
@param {ClientRect} targetRect - Rectangle of target element.
@returns {ClientRect} Intersection rectangle.
Computes intersection rectangle between two rectangles .