src/IntersectionObservation.js
function getIntersection(container, target, containterRect, targetRect) {
    let intersecRect    = targetRect,
        parent          = target.parentNode,
        rootReached     = false;

    while (!rootReached) {
        let parentRect = null;

        if (parent === container || parent.nodeType !== 1) {
            rootReached = true;
            parentRect = containterRect;
        } else if (window.getComputedStyle(parent).overflow !== 'visible') {
            parentRect = getRectangle(parent);
        }

        if (parentRect) {
            intersecRect = computeIntersection(intersecRect, parentRect);
        }

        parent = parent.parentNode;
    }

    return intersecRect;
}
function getIntersection(container, target, containterRect, targetRect) {
    let intersecRect    = targetRect,
        parent          = target.parentNode,
        rootReached     = false;

    while (!rootReached) {
        let parentRect = null;

        if (parent === container || parent.nodeType !== 1) {
            rootReached = true;
            parentRect = containterRect;
        } else if (window.getComputedStyle(parent).overflow !== 'visible') {
            parentRect = getRectangle(parent);
        }

        if (parentRect) {
            intersecRect = computeIntersection(intersecRect, parentRect);
        }

        parent = parent.parentNode;
    }

    return intersecRect;
}
function getIntersection ( container , target , containterRect , targetRect ) { let intersecRect = targetRect , parent = target . parentNode , rootReached = false ; while ( ! rootReached ) { let parentRect = null ; if ( parent === container || parent . nodeType !== 1 ) { rootReached = true ; parentRect = containterRect ; } else if ( window . getComputedStyle ( parent ) . overflow !== 'visible' ) { parentRect = getRectangle ( parent ) ; } if ( parentRect ) { intersecRect = computeIntersection ( intersecRect , parentRect ) ; } parent = parent . parentNode ; } return intersecRect ; }
Finds intersection rectangle of provided elements.

@param {Element} container - Container element.
@param {Element} target - Target element.
@param {ClientRect} targetRect - Rectangle of target element.
@param {ClientRect} containterRect - Rectangle of container element.
Finds intersection rectangle of provided elements .