demo/load-event/js/libs/jquery.isinview/jquery.isinview-1.0.3.js
function _isInView ( elem, config ) {

        var containerWidth, containerHeight, hTolerance, vTolerance, rect,
            container = config.container,
            $container = config.$container,
            cache = config.cache,
            elemInView = true;

        if ( elem === container ) throw new Error( "Invalid container: is the same as the element" );

        // When hidden elements are ignored, we check if an element consumes space in the document. And we bail out
        // immediately if it doesn't.
        //
        // The test employed for this works in the vast majority of cases, but there is a limitation. We use offsetWidth
        // and offsetHeight, which considers the content (incl. borders) but ignores margins. Zero-size content with a
        // margin might actually consume space sometimes, but it won't be detected (see http://jsbin.com/tiwabo/3).
        //
        // That said, the definition of visibility and the actual test are the same as in jQuery :visible.
        if ( config.excludeHidden && !( elem.offsetWidth > 0 && elem.offsetHeight > 0 ) ) return false;

        if ( config.useHorizontal ) containerWidth = getNetContainerWidth( $container, config.containerIsWindow, cache );
        if ( config.useVertical ) containerHeight = getNetContainerHeight( $container, config.containerIsWindow, cache );

        // Convert tolerance to a px value (if given as a percentage)
        hTolerance = cache.hTolerance !== undefined ? cache.hTolerance : ( cache.hTolerance = config.toleranceType === "add" ? config.tolerance : containerWidth * config.tolerance );
        vTolerance = cache.vTolerance !== undefined ? cache.vTolerance : ( cache.vTolerance = config.toleranceType === "add" ? config.tolerance : containerHeight * config.tolerance );

        // We can safely use getBoundingClientRect without a fallback. Its core properties (top, left, bottom, right)
        // are supported on the desktop for ages (IE5+). On mobile, too: supported from Blackberry 6+ (2010), iOS 4
        // (2010, iPhone 3GS+), according to the jQuery source comment in $.fn.offset.
        //
        // In oldIE (up to IE8), the coordinates were 2px off in each dimension because the "viewport" began at (2,2) of
        // the window. Can be feature-tested by creating an absolutely positioned div at (0,0) and reading the rect
        // coordinates. Won't be fixed here because the quirk is too minor to justify the overhead, just for oldIE.
        //
        // (See http://stackoverflow.com/a/10231202/508355 and Zakas, Professional Javascript (2012), p. 406)

        rect = config.borderBox ? elem.getBoundingClientRect() : getContentRect( elem );
        if ( ! config.containerIsWindow ) rect = getRelativeRect( rect, $container, cache );

        if ( config.partially ) {
            if ( config.useVertical ) elemInView = rect.top < containerHeight + vTolerance && rect.bottom > -vTolerance;
            if ( config.useHorizontal ) elemInView = elemInView && rect.left < containerWidth + hTolerance && rect.right > -hTolerance;
        } else {
            if ( config.useVertical ) elemInView = rect.top >= -vTolerance && rect.top < containerHeight + vTolerance && rect.bottom > -vTolerance && rect.bottom <= containerHeight + vTolerance;
            if ( config.useHorizontal ) elemInView = elemInView && rect.left >= -hTolerance && rect.left < containerWidth + hTolerance && rect.right > -hTolerance && rect.right <= containerWidth + hTolerance;
        }

        return elemInView;

    }
function _isInView ( elem, config ) {

        var containerWidth, containerHeight, hTolerance, vTolerance, rect,
            container = config.container,
            $container = config.$container,
            cache = config.cache,
            elemInView = true;

        if ( elem === container ) throw new Error( "Invalid container: is the same as the element" );

        // When hidden elements are ignored, we check if an element consumes space in the document. And we bail out
        // immediately if it doesn't.
        //
        // The test employed for this works in the vast majority of cases, but there is a limitation. We use offsetWidth
        // and offsetHeight, which considers the content (incl. borders) but ignores margins. Zero-size content with a
        // margin might actually consume space sometimes, but it won't be detected (see http://jsbin.com/tiwabo/3).
        //
        // That said, the definition of visibility and the actual test are the same as in jQuery :visible.
        if ( config.excludeHidden && !( elem.offsetWidth > 0 && elem.offsetHeight > 0 ) ) return false;

        if ( config.useHorizontal ) containerWidth = getNetContainerWidth( $container, config.containerIsWindow, cache );
        if ( config.useVertical ) containerHeight = getNetContainerHeight( $container, config.containerIsWindow, cache );

        // Convert tolerance to a px value (if given as a percentage)
        hTolerance = cache.hTolerance !== undefined ? cache.hTolerance : ( cache.hTolerance = config.toleranceType === "add" ? config.tolerance : containerWidth * config.tolerance );
        vTolerance = cache.vTolerance !== undefined ? cache.vTolerance : ( cache.vTolerance = config.toleranceType === "add" ? config.tolerance : containerHeight * config.tolerance );

        // We can safely use getBoundingClientRect without a fallback. Its core properties (top, left, bottom, right)
        // are supported on the desktop for ages (IE5+). On mobile, too: supported from Blackberry 6+ (2010), iOS 4
        // (2010, iPhone 3GS+), according to the jQuery source comment in $.fn.offset.
        //
        // In oldIE (up to IE8), the coordinates were 2px off in each dimension because the "viewport" began at (2,2) of
        // the window. Can be feature-tested by creating an absolutely positioned div at (0,0) and reading the rect
        // coordinates. Won't be fixed here because the quirk is too minor to justify the overhead, just for oldIE.
        //
        // (See http://stackoverflow.com/a/10231202/508355 and Zakas, Professional Javascript (2012), p. 406)

        rect = config.borderBox ? elem.getBoundingClientRect() : getContentRect( elem );
        if ( ! config.containerIsWindow ) rect = getRelativeRect( rect, $container, cache );

        if ( config.partially ) {
            if ( config.useVertical ) elemInView = rect.top < containerHeight + vTolerance && rect.bottom > -vTolerance;
            if ( config.useHorizontal ) elemInView = elemInView && rect.left < containerWidth + hTolerance && rect.right > -hTolerance;
        } else {
            if ( config.useVertical ) elemInView = rect.top >= -vTolerance && rect.top < containerHeight + vTolerance && rect.bottom > -vTolerance && rect.bottom <= containerHeight + vTolerance;
            if ( config.useHorizontal ) elemInView = elemInView && rect.left >= -hTolerance && rect.left < containerWidth + hTolerance && rect.right > -hTolerance && rect.right <= containerWidth + hTolerance;
        }

        return elemInView;

    }
function _isInView ( elem , config ) { var containerWidth , containerHeight , hTolerance , vTolerance , rect , container = config . container , $container = config . $container , cache = config . cache , elemInView = true ; if ( elem === container ) throw new Error ( "Invalid container: is the same as the element" ) ; // When hidden elements are ignored, we check if an element consumes space in the document. And we bail out // immediately if it doesn't. // // The test employed for this works in the vast majority of cases, but there is a limitation. We use offsetWidth // and offsetHeight, which considers the content (incl. borders) but ignores margins. Zero-size content with a // margin might actually consume space sometimes, but it won't be detected (see http://jsbin.com/tiwabo/3). // // That said, the definition of visibility and the actual test are the same as in jQuery :visible. if ( config . excludeHidden && ! ( elem . offsetWidth > 0 && elem . offsetHeight > 0 ) ) return false ; if ( config . useHorizontal ) containerWidth = getNetContainerWidth ( $container , config . containerIsWindow , cache ) ; if ( config . useVertical ) containerHeight = getNetContainerHeight ( $container , config . containerIsWindow , cache ) ; // Convert tolerance to a px value (if given as a percentage) hTolerance = cache . hTolerance !== undefined ? cache . hTolerance : ( cache . hTolerance = config . toleranceType === "add" ? config . tolerance : containerWidth * config . tolerance ) ; vTolerance = cache . vTolerance !== undefined ? cache . vTolerance : ( cache . vTolerance = config . toleranceType === "add" ? config . tolerance : containerHeight * config . tolerance ) ; // We can safely use getBoundingClientRect without a fallback. Its core properties (top, left, bottom, right) // are supported on the desktop for ages (IE5+). On mobile, too: supported from Blackberry 6+ (2010), iOS 4 // (2010, iPhone 3GS+), according to the jQuery source comment in $.fn.offset. // // In oldIE (up to IE8), the coordinates were 2px off in each dimension because the "viewport" began at (2,2) of // the window. Can be feature-tested by creating an absolutely positioned div at (0,0) and reading the rect // coordinates. Won't be fixed here because the quirk is too minor to justify the overhead, just for oldIE. // // (See http://stackoverflow.com/a/10231202/508355 and Zakas, Professional Javascript (2012), p. 406) rect = config . borderBox ? elem . getBoundingClientRect ( ) : getContentRect ( elem ) ; if ( ! config . containerIsWindow ) rect = getRelativeRect ( rect , $container , cache ) ; if ( config . partially ) { if ( config . useVertical ) elemInView = rect . top < containerHeight + vTolerance && rect . bottom > - vTolerance ; if ( config . useHorizontal ) elemInView = elemInView && rect . left < containerWidth + hTolerance && rect . right > - hTolerance ; } else { if ( config . useVertical ) elemInView = rect . top >= - vTolerance && rect . top < containerHeight + vTolerance && rect . bottom > - vTolerance && rect . bottom <= containerHeight + vTolerance ; if ( config . useHorizontal ) elemInView = elemInView && rect . left >= - hTolerance && rect . left < containerWidth + hTolerance && rect . right > - hTolerance && rect . right <= containerWidth + hTolerance ; } return elemInView ; }
Returns if an element is in view, with regard to a given configuration.

The configuration is built with _prepareConfig().

@param {HTMLElement}        elem
@param {Object}             config
@param {HTMLElement|Window} config.container
@param {jQuery}             config.$container
@param {boolean}            config.containerIsWindow
@param {Object}             config.cache
@param {boolean}            config.useHorizontal
@param {boolean}            config.useVertical
@param {boolean}            config.partially
@param {boolean}            config.excludeHidden
@param {boolean}            config.borderBox
@param {number}             config.tolerance
@param {string}             config.toleranceType

@returns {boolean}
Returns if an element is in view with regard to a given configuration .