src/utils/ViewUtils.js
function getElementClipSize($view, elementRect) {
        var delta,
            clip = { top: 0, right: 0, bottom: 0, left: 0 },
            viewOffset = $view.offset() || { top: 0, left: 0};

        // Check if element extends below viewport
        delta = (elementRect.top + elementRect.height) - (viewOffset.top + $view.height());
        if (delta > 0) {
            clip.bottom = delta;
        }

        // Check if element extends above viewport
        delta = viewOffset.top - elementRect.top;
        if (delta > 0) {
            clip.top = delta;
        }

        // Check if element extends to the left of viewport
        delta = viewOffset.left - elementRect.left;
        if (delta > 0) {
            clip.left = delta;
        }

        // Check if element extends to the right of viewport
        delta = (elementRect.left + elementRect.width) - (viewOffset.left + $view.width());
        if (delta > 0) {
            clip.right = delta;
        }

        return clip;
    }
function getElementClipSize($view, elementRect) {
        var delta,
            clip = { top: 0, right: 0, bottom: 0, left: 0 },
            viewOffset = $view.offset() || { top: 0, left: 0};

        // Check if element extends below viewport
        delta = (elementRect.top + elementRect.height) - (viewOffset.top + $view.height());
        if (delta > 0) {
            clip.bottom = delta;
        }

        // Check if element extends above viewport
        delta = viewOffset.top - elementRect.top;
        if (delta > 0) {
            clip.top = delta;
        }

        // Check if element extends to the left of viewport
        delta = viewOffset.left - elementRect.left;
        if (delta > 0) {
            clip.left = delta;
        }

        // Check if element extends to the right of viewport
        delta = (elementRect.left + elementRect.width) - (viewOffset.left + $view.width());
        if (delta > 0) {
            clip.right = delta;
        }

        return clip;
    }
function getElementClipSize ( $view , elementRect ) { var delta , clip = { top : 0 , right : 0 , bottom : 0 , left : 0 } , viewOffset = $view . offset ( ) || { top : 0 , left : 0 } ; // Check if element extends below viewport delta = ( elementRect . top + elementRect . height ) - ( viewOffset . top + $view . height ( ) ) ; if ( delta > 0 ) { clip . bottom = delta ; } // Check if element extends above viewport delta = viewOffset . top - elementRect . top ; if ( delta > 0 ) { clip . top = delta ; } // Check if element extends to the left of viewport delta = viewOffset . left - elementRect . left ; if ( delta > 0 ) { clip . left = delta ; } // Check if element extends to the right of viewport delta = ( elementRect . left + elementRect . width ) - ( viewOffset . left + $view . width ( ) ) ; if ( delta > 0 ) { clip . right = delta ; } return clip ; }
Determine how much of an element rect is clipped in view.

@param {!DOMElement} $view - A jQuery scrolling container
@param {!{top: number, left: number, height: number, width: number}}
elementRect - rectangle of element's default position/size
@return {{top: number, right: number, bottom: number, left: number}}
amount element rect is clipped in each direction
Determine how much of an element rect is clipped in view .